summaryrefslogtreecommitdiffstats
path: root/Python/compile.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2002-08-16 02:48:11 (GMT)
committerGuido van Rossum <guido@python.org>2002-08-16 02:48:11 (GMT)
commitb7164621fa6619b45001eff50417d189c088d621 (patch)
tree3971697d10be4b21bf4d0b897ab49b4470051cbe /Python/compile.c
parent80703c89308a2adbdece4c8c044e7ba4d3069f91 (diff)
downloadcpython-b7164621fa6619b45001eff50417d189c088d621.zip
cpython-b7164621fa6619b45001eff50417d189c088d621.tar.gz
cpython-b7164621fa6619b45001eff50417d189c088d621.tar.bz2
Add warnings for arguments named None. All set. (I could add a
warning for 'global None', but that's either accompanied by an assignment to None, which will trigger a warning, or not, in which case it's harmless. :-)
Diffstat (limited to 'Python/compile.c')
-rw-r--r--Python/compile.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/Python/compile.c b/Python/compile.c
index 0edbc52..0109fe5 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -5025,6 +5025,14 @@ symtable_add_def(struct symtable *st, char *name, int flag)
char buffer[MANGLE_LEN];
int ret;
+ /* Warn about None, except inside a tuple (where the assignment
+ code already issues a warning). */
+ if ((flag & DEF_PARAM) && !(flag & DEF_INTUPLE) &&
+ *name == 'N' && strcmp(name, "None") == 0)
+ {
+ if (symtable_warn(st, "argument named None"))
+ return -1;
+ }
if (_Py_Mangle(st->st_private, name, buffer, sizeof(buffer)))
name = buffer;
if ((s = PyString_InternFromString(name)) == NULL)
@@ -5310,7 +5318,7 @@ symtable_funcdef(struct symtable *st, node *n)
}
/* The next two functions parse the argument tuple.
- symtable_default_arg() checks for names in the default arguments,
+ symtable_default_args() checks for names in the default arguments,
which are references in the defining scope. symtable_params()
parses the parameter names, which are defined in the function's
body.