diff Python/compile.c @ 24858:592406e0c9b0 legacy-trunk

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. :-)
author Guido van Rossum <guido@python.org>
date Fri, 16 Aug 2002 02:48:11 +0000
parents 87448a228cca
children be2868a63ed5
line wrap: on
line diff
--- a/Python/compile.c	Fri Aug 16 02:27:15 2002 +0000
+++ b/Python/compile.c	Fri Aug 16 02:48:11 2002 +0000
@@ -5025,6 +5025,14 @@
 	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 @@
 }
 
 /* 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.