diff Python/compile.c @ 14077:b678491f7e11 legacy-trunk

Disallow "import mod.submod as m", because the result is ambiguous. Does it load mod.submod as m, or mod as m ? Both can be achieved differently, and unambiguously. Also attempt to document this restriction (editor appreciated!) Note that this is an artificial check during compile, because incorporating this in the grammar is hard, and then adjusting the compiler to do the right thing with the right nodes is harder.
author Thomas Wouters <thomas@python.org>
date Sat, 19 Aug 2000 20:55:02 +0000
parents 920fc2868543
children 468481135c49
line wrap: on
line diff
--- a/Python/compile.c	Sat Aug 19 16:55:31 2000 +0000
+++ b/Python/compile.c	Sat Aug 19 20:55:02 2000 +0000
@@ -2139,7 +2139,8 @@
 			com_addopname(c, IMPORT_NAME, CHILD(subn, 0));
 			com_push(c, 1);
 			if (NCH(subn) > 1) {
-				if (strcmp(STR(CHILD(subn, 1)), "as") != 0) {
+				if (strcmp(STR(CHILD(subn, 1)), "as") != 0 ||
+				    NCH(CHILD(subn, 0)) > 1) {
 					com_error(c, PyExc_SyntaxError,
 						  "invalid syntax");
 					return;