[Python-checkins] python/dist/src/Python symtable.c, 2.10.8.35, 2.10.8.36

nascheme@users.sourceforge.net nascheme at users.sourceforge.net
Wed Aug 31 03:48:53 CEST 2005


Update of /cvsroot/python/python/dist/src/Python
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15719/Python

Modified Files:
      Tag: ast-branch
	symtable.c 
Log Message:
Generate SyntaxWarning for 'import *' at non-module scope.


Index: symtable.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/symtable.c,v
retrieving revision 2.10.8.35
retrieving revision 2.10.8.36
diff -u -d -r2.10.8.35 -r2.10.8.36
--- symtable.c	31 Aug 2005 00:25:23 -0000	2.10.8.35
+++ symtable.c	31 Aug 2005 01:48:41 -0000	2.10.8.36
@@ -903,7 +903,8 @@
 					PyOS_snprintf(buf, sizeof(buf),
 						      GLOBAL_AFTER_USE,
 						      c_name);
-				symtable_warn(st, buf);
+				if (!symtable_warn(st, buf))
+                                    return 0;
 			}
 			if (!symtable_add_def(st, name, DEF_GLOBAL))
 				return 0;
@@ -1128,6 +1129,11 @@
 	if (strcmp(PyString_AS_STRING(name), "*"))
 	    return symtable_add_def(st, name, DEF_IMPORT);
 	else {
+            if (st->st_cur->ste_type != ModuleBlock) {
+                if (!symtable_warn(st,
+                                   "import * only allowed at module level"))
+                    return 0;
+            }
 	    st->st_cur->ste_optimized = 0;
 	    return 1;
 	}



More information about the Python-checkins mailing list