Issue 549213: warn on assignment to None, True, False (original) (raw)

Created on 2002-04-26 19:14 by jhylton, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
diff jhylton,2002-04-26 20:30
Messages (10)
msg39723 - (view) Author: Jeremy Hylton (jhylton) (Python triager) Date: 2002-04-26 19:14
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.
msg39724 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-04-26 19:28
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)".
msg39725 - (view) Author: Jeremy Hylton (jhylton) (Python triager) Date: 2002-04-26 19:34
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.
msg39726 - (view) Author: Jeremy Hylton (jhylton) (Python triager) Date: 2002-04-26 20:30
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.
msg39727 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-04-26 20:44
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.
msg39728 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2002-12-14 14:17
Logged In: YES user_id=21627 Is this going to be part of Python 2.3?
msg39729 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-12-16 20:15
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.
msg39730 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-12-23 16:35
Logged In: YES user_id=6380 Checked in, compile.c 2.269.
msg39731 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-12-23 18:34
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.
msg39732 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2004-08-18 11:37
Logged In: YES user_id=21627 The patch is out of date: assignment to None is now an error.
History
Date User Action Args
2022-04-10 16:05:16 admin set github: 36508
2002-04-26 19:14:27 jhylton create