[Python-checkins] CVS: python/dist/src/Python compile.c,2.172,2.173
Jeremy Hylton
jhylton@users.sourceforge.net
Mon, 26 Feb 2001 21:16:00 -0800
- Previous message: [Python-checkins] CVS: python/dist/src configure.in,1.206,1.207 configure,1.198,1.199 config.h.in,2.87,2.88 acconfig.h,1.43,1.44 Makefile.pre.in,1.23,1.24
- Next message: [Python-checkins] CVS: python/dist/src/Lib urllib.py,1.117,1.118
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv2358
Modified Files:
compile.c
Log Message:
Add warnings about undefined "global"
SF bug #233532
XXX Can't figure out how to write test cases that work with warnings
Index: compile.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v
retrieving revision 2.172
retrieving revision 2.173
diff -C2 -r2.172 -r2.173
*** compile.c 2001/02/27 04:23:34 2.172
--- compile.c 2001/02/27 05:15:57 2.173
***************
*** 4854,4857 ****
--- 4854,4886 ----
for (i = 1; i < NCH(n); i += 2) {
char *name = STR(CHILD(n, i));
+ int flags;
+
+ flags = symtable_lookup(st, name);
+ if (flags && flags != DEF_GLOBAL) {
+ char buf[500];
+ if (flags & DEF_PARAM) {
+ PyErr_Format(PyExc_SyntaxError,
+ "name '%.400s' is local and global",
+ PyString_AS_STRING(name));
+ set_error_location(st->st_filename,
+ st->st_cur->ste_lineno);
+ st->st_errors++;
+ return;
+ } else if (flags & DEF_LOCAL) {
+ sprintf(buf, GLOBAL_AFTER_ASSIGN, name);
+ if (PyErr_Warn(PyExc_SyntaxWarning,
+ buf) < 0) {
+ /* XXX set line number? */
+ st->st_errors++;
+ }
+ } else {
+ sprintf(buf, GLOBAL_AFTER_USE, name);
+ if (PyErr_Warn(PyExc_SyntaxWarning,
+ buf) < 0) {
+ /* XXX set line number? */
+ st->st_errors++;
+ }
+ }
+ }
symtable_add_def(st, name, DEF_GLOBAL);
}
- Previous message: [Python-checkins] CVS: python/dist/src configure.in,1.206,1.207 configure,1.198,1.199 config.h.in,2.87,2.88 acconfig.h,1.43,1.44 Makefile.pre.in,1.23,1.24
- Next message: [Python-checkins] CVS: python/dist/src/Lib urllib.py,1.117,1.118
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]