[Python-checkins] CVS: python/dist/src/Python compile.c,2.180,2.181
Jeremy Hylton
jhylton@users.sourceforge.net
Wed, 28 Feb 2001 15:44:48 -0800
Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv14364/Python
Modified Files:
compile.c
Log Message:
Warn about global statement at the module level.
Do better accounting for global variables.
Index: compile.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v
retrieving revision 2.180
retrieving revision 2.181
diff -C2 -r2.180 -r2.181
*** compile.c 2001/02/28 22:54:51 2.180
--- compile.c 2001/02/28 23:44:45 2.181
***************
*** 4179,4183 ****
char buf[500];
PyObject *children, *v;
! PySymtableEntryObject *child;
int i;
--- 4179,4183 ----
char buf[500];
PyObject *children, *v;
! PySymtableEntryObject *child = NULL;
int i;
***************
*** 4203,4207 ****
break;
}
!
sprintf(buf, "local name '%.100s' in '%.100s' shadows "
"use of '%.100s' as global in nested scope '%.100s'",
--- 4203,4209 ----
break;
}
!
! assert(child != NULL);
!
sprintf(buf, "local name '%.100s' in '%.100s' shadows "
"use of '%.100s' as global in nested scope '%.100s'",
***************
*** 4329,4332 ****
--- 4331,4338 ----
implicit) < 0)
goto fail;
+ v = PyInt_FromLong(flags);
+ if (PyDict_SetItem(st->st_global, name, v))
+ goto fail;
+ Py_DECREF(v);
}
}
***************
*** 4361,4364 ****
--- 4367,4371 ----
st->st_errors = 0;
st->st_tmpname = 0;
+ st->st_global_star = 0;
st->st_private = NULL;
return st;
***************
*** 4923,4926 ****
--- 4930,4939 ----
int i;
+ if (st->st_nscopes == 1) {
+ if (symtable_warn(st,
+ "global statement has no meaning at module level") < 0)
+ return;
+ }
+
for (i = 1; i < NCH(n); i += 2) {
char *name = STR(CHILD(n, i));
***************
*** 4992,4995 ****
--- 5005,5010 ----
if (TYPE(CHILD(n, 3)) == STAR) {
st->st_cur->ste_optimized |= OPT_IMPORT_STAR;
+ if (st->st_nscopes == 1)
+ st->st_global_star = 1;
} else {
for (i = 3; i < NCH(n); i += 2) {