[Patches] [ python-Patches-549213 ] warn on assignment to None, True, False
noreply@sourceforge.net
noreply@sourceforge.net
Mon, 23 Dec 2002 10:34:09 -0800
Patches item #549213, was opened at 2002-04-26 15:14
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=549213&group_id=5470
Category: Parser/Compiler
Group: None
>Status: Open
Resolution: None
Priority: 5
Submitted By: Jeremy Hylton (jhylton)
Assigned to: Jeremy Hylton (jhylton)
Summary: warn on assignment to None, True, False
Initial Comment:
This patch issues a warning when None, True, or False
is assigned to. I don't know what the text of the
warning should say, but that's a minor matter.
----------------------------------------------------------------------
>Comment By: Guido van Rossum (gvanrossum)
Date: 2002-12-23 13:34
Message:
Logged In: YES
user_id=6380
Alas, I spoke too soon. This patch broke some unit tests,
e.g. test_grammar.py; its seems it doesn't correctly
traverse into tuple-shaped arguments. It also causes some
warnings because there's code out there that assigns to True
and False in case it's being run under older Python versions.
----------------------------------------------------------------------
Comment By: Guido van Rossum (gvanrossum)
Date: 2002-12-23 11:35
Message:
Logged In: YES
user_id=6380
Checked in, compile.c 2.269.
----------------------------------------------------------------------
Comment By: Guido van Rossum (gvanrossum)
Date: 2002-12-16 15:15
Message:
Logged In: YES
user_id=6380
Yes, I'd like it to be. I think the nits (duplicate warnings
in some cases) can be banged out during alpha testing.
Jeremy, can you check this in? It needs a small note in
Misc/NEWS.
----------------------------------------------------------------------
Comment By: Martin v. Löwis (loewis)
Date: 2002-12-14 09:17
Message:
Logged In: YES
user_id=21627
Is this going to be part of Python 2.3?
----------------------------------------------------------------------
Comment By: Guido van Rossum (gvanrossum)
Date: 2002-04-26 16:44
Message:
Logged In: YES
user_id=6380
Better. Some strange behavior remains:
from foo import None # gives three warnings!
import None # gives two warnings!
We need a test suite that systematically tests all cases.
----------------------------------------------------------------------
Comment By: Jeremy Hylton (jhylton)
Date: 2002-04-26 16:30
Message:
Logged In: YES
user_id=31392
Here's an improved pass, although the calls are getting a
bit messy. Not sure how worried I am, since I'd like to
replace this code anyway. (The worry is that I don't get
around to replacing it before 2.3.)
Also, fix com_arglist() to do only the work that is necessary.
----------------------------------------------------------------------
Comment By: Jeremy Hylton (jhylton)
Date: 2002-04-26 15:34
Message:
Logged In: YES
user_id=31392
Right. I'll have to fiddle the patch to make the check into
a function and we can see where else it should be applied.
----------------------------------------------------------------------
Comment By: Guido van Rossum (gvanrossum)
Date: 2002-04-26 15:28
Message:
Logged In: YES
user_id=6380
Nice, but doesn't catch enough cases. E.g. using None as an
argument name, assigning to an attribute named None, "import
foo.None", "from foo.None import bar", "from None import
bar", "from None.foo import bar", using None as a keyword
argument in a call: "f(1, 2, None=3)".
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=549213&group_id=5470