This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2008年03月17日 19:19 by brett.cannon, last changed 2022年04月11日 14:56 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| bool_assign.patch | benjamin.peterson, 2008年03月17日 21:23 | |||
| bool_assign2.patch | benjamin.peterson, 2008年03月17日 22:59 | rephrase the warnings | ||
| bool_assign3.patch | benjamin.peterson, 2008年03月19日 18:33 | caught more places | ||
| bool_assign4.patch | benjamin.peterson, 2008年03月19日 18:50 | added a test | ||
| bool_assign5.patch | benjamin.peterson, 2008年05月03日 16:59 | |||
| bool_assign6.patch | benjamin.peterson, 2008年05月17日 20:03 | |||
| bool_assign7.patch | benjamin.peterson, 2008年06月08日 17:07 | |||
| Messages (28) | |||
|---|---|---|---|
| msg63717 - (view) | Author: Brett Cannon (brett.cannon) * (Python committer) | Date: 2008年03月17日 19:19 | |
Assigning to True of False should raise at least a Py3K warning (maybe something more severe?). |
|||
| msg63765 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2008年03月17日 20:41 | |
I would like to review the patch on this one. I think it should limit itself to the True and False in builtin. It would be *very* expensive to check for every assignment in every possible namespace. |
|||
| msg63768 - (view) | Author: Brett Cannon (brett.cannon) * (Python committer) | Date: 2008年03月17日 20:45 | |
On Mon, Mar 17, 2008 at 3:41 PM, Raymond Hettinger <report@bugs.python.org> wrote: > > Raymond Hettinger <rhettinger@users.sourceforge.net> added the comment: > > I would like to review the patch on this one. > > I think it should limit itself to the True and False in builtin. It > would be *very* expensive to check for every assignment in every > possible namespace. > It shouldn't be expensive when the parser does the check (just like with SyntaxError for None). |
|||
| msg63777 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2008年03月17日 21:03 | |
The parser approach should be fine. |
|||
| msg63779 - (view) | Author: Benjamin Peterson (benjamin.peterson) * (Python committer) | Date: 2008年03月17日 21:06 | |
I'm working on it. |
|||
| msg63782 - (view) | Author: Benjamin Peterson (benjamin.peterson) * (Python committer) | Date: 2008年03月17日 21:23 | |
This patch alters the parser to warn for assignment to True and False. Enjoy! |
|||
| msg63784 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2008年03月17日 21:27 | |
Looks fine. Please apply. |
|||
| msg63796 - (view) | Author: Benjamin Peterson (benjamin.peterson) * (Python committer) | Date: 2008年03月17日 22:37 | |
Sorry, I don't permission. |
|||
| msg63797 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2008年03月17日 22:39 | |
I'll apply when I get a chance. |
|||
| msg63799 - (view) | Author: Alexander Belopolsky (belopolsky) * (Python committer) | Date: 2008年03月17日 22:53 | |
This is a minor concern, but existing -3 warnings refer to python 3.0 and above as "3.x", not 'Py3K'. It would be nice to preserve consistency. |
|||
| msg63802 - (view) | Author: Benjamin Peterson (benjamin.peterson) * (Python committer) | Date: 2008年03月17日 22:59 | |
"A Foolish Consistency is the Hobgoblin of Little Minds" This update makes the warnings say 3.x. |
|||
| msg64015 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2008年03月18日 23:35 | |
Back to Brett for application. |
|||
| msg64075 - (view) | Author: Brett Cannon (brett.cannon) * (Python committer) | Date: 2008年03月19日 17:34 | |
Actually, the patch is incomplete. You can still do assignment through things such as ``def True(): pass``. If you go through ast.c and find the various places None is protected (search for \"None\" and note the places where an ast_error() call is made) you should put the warnings there. |
|||
| msg64081 - (view) | Author: Benjamin Peterson (benjamin.peterson) * (Python committer) | Date: 2008年03月19日 18:33 | |
Wow! I never realized how many ways you could possibly assign to something. I found all the None assignments and put the True/False ones under it. |
|||
| msg64083 - (view) | Author: Benjamin Peterson (benjamin.peterson) * (Python committer) | Date: 2008年03月19日 18:50 | |
I just added on a test. |
|||
| msg64086 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2008年03月19日 19:09 | |
FWIW, I don't think it's important to catch every possible assignment. Add warnings for the common cases and declare victory. |
|||
| msg64089 - (view) | Author: Benjamin Peterson (benjamin.peterson) * (Python committer) | Date: 2008年03月19日 19:33 | |
Do you think we should remove some? |
|||
| msg64318 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2008年03月22日 11:23 | |
Keep what you've got but don't lose sleep if some offbeat case is not covered. |
|||
| msg64981 - (view) | Author: Benjamin Peterson (benjamin.peterson) * (Python committer) | Date: 2008年04月05日 15:18 | |
Brett, shall I apply? |
|||
| msg65953 - (view) | Author: Brett Cannon (brett.cannon) * (Python committer) | Date: 2008年04月29日 02:17 | |
If Raymond says it's fine, then it's also fine by me. |
|||
| msg65985 - (view) | Author: Benjamin Peterson (benjamin.peterson) * (Python committer) | Date: 2008年04月29日 21:48 | |
As I looked over the code again, I realized that it doesn't help to just do a normal warning while compiling because the line number isn't supplied. You have to use PyWarn_Explicit for that (see the warning about backquotes). Since the filename (in the compiling struct) isn't passed around to all ast helpers, you can't warn in every function. Therefore, I have #2720. |
|||
| msg66157 - (view) | Author: Benjamin Peterson (benjamin.peterson) * (Python committer) | Date: 2008年05月03日 16:59 | |
Okay, now that #2720 was dealt with, here's another (close to final) patch. I added an ast_warn help function. When -Werror is used, the warnings are converted to SyntaxErrors. Raymond or Brett, if you could take a look, that would be great. Thanks! |
|||
| msg67014 - (view) | Author: Benjamin Peterson (benjamin.peterson) * (Python committer) | Date: 2008年05月17日 20:03 | |
I'm attaching a new patch with changes made from the Georg's comments. |
|||
| msg67819 - (view) | Author: Benjamin Peterson (benjamin.peterson) * (Python committer) | Date: 2008年06月08日 01:43 | |
Georg, can I apply? |
|||
| msg67824 - (view) | Author: Georg Brandl (georg.brandl) * (Python committer) | Date: 2008年06月08日 08:23 | |
Hmm, I'd even go a step further and factor out the whole checking for invalid/warnable names, like in Py3k's forbidden_name. Also the warning text shouldn't start with uppercase and end in a full stop. |
|||
| msg67840 - (view) | Author: Benjamin Peterson (benjamin.peterson) * (Python committer) | Date: 2008年06月08日 17:07 | |
Here's a much better patch that delegates checking to a helper. |
|||
| msg67846 - (view) | Author: Georg Brandl (georg.brandl) * (Python committer) | Date: 2008年06月08日 18:06 | |
The macro at the top of the patch should be removed, then this can be checked in. |
|||
| msg67849 - (view) | Author: Benjamin Peterson (benjamin.peterson) * (Python committer) | Date: 2008年06月08日 23:10 | |
Done in r64044. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:56:32 | admin | set | github: 46602 |
| 2008年06月08日 23:10:45 | benjamin.peterson | set | status: open -> closed resolution: accepted -> fixed messages: + msg67849 |
| 2008年06月08日 18:06:21 | georg.brandl | set | resolution: accepted messages: + msg67846 |
| 2008年06月08日 17:07:08 | benjamin.peterson | set | files:
+ bool_assign7.patch messages: + msg67840 |
| 2008年06月08日 08:23:18 | georg.brandl | set | messages: + msg67824 |
| 2008年06月08日 01:43:58 | benjamin.peterson | set | assignee: brett.cannon -> georg.brandl messages: + msg67819 nosy: + georg.brandl |
| 2008年05月18日 21:09:17 | benjamin.peterson | set | assignee: benjamin.peterson -> brett.cannon |
| 2008年05月17日 20:04:14 | benjamin.peterson | set | files:
+ bool_assign6.patch messages: + msg67014 |
| 2008年05月03日 16:59:21 | benjamin.peterson | set | files:
+ bool_assign5.patch messages: + msg66157 |
| 2008年05月02日 21:15:33 | benjamin.peterson | set | dependencies: + make compiling struct be passed around to all ast helpers |
| 2008年04月29日 21:48:54 | benjamin.peterson | set | messages: + msg65985 |
| 2008年04月29日 02:17:59 | brett.cannon | set | assignee: brett.cannon -> benjamin.peterson messages: + msg65953 |
| 2008年04月05日 15:18:51 | benjamin.peterson | set | messages: + msg64981 |
| 2008年03月22日 11:23:15 | rhettinger | set | assignee: rhettinger -> brett.cannon messages: + msg64318 |
| 2008年03月19日 21:06:20 | brett.cannon | set | assignee: brett.cannon -> rhettinger |
| 2008年03月19日 19:33:21 | benjamin.peterson | set | messages: + msg64089 |
| 2008年03月19日 19:09:50 | rhettinger | set | messages: + msg64086 |
| 2008年03月19日 18:50:17 | benjamin.peterson | set | files:
+ bool_assign4.patch messages: + msg64083 |
| 2008年03月19日 18:33:55 | benjamin.peterson | set | files:
+ bool_assign3.patch messages: + msg64081 |
| 2008年03月19日 17:34:01 | brett.cannon | set | resolution: accepted -> (no value) messages: + msg64075 |
| 2008年03月18日 23:35:14 | rhettinger | set | assignee: rhettinger -> brett.cannon messages: + msg64015 |
| 2008年03月17日 22:59:07 | benjamin.peterson | set | files:
+ bool_assign2.patch messages: + msg63802 |
| 2008年03月17日 22:53:09 | belopolsky | set | nosy:
+ belopolsky messages: + msg63799 |
| 2008年03月17日 22:39:41 | rhettinger | set | assignee: rhettinger messages: + msg63797 |
| 2008年03月17日 22:37:29 | benjamin.peterson | set | messages: + msg63796 |
| 2008年03月17日 21:27:46 | rhettinger | set | resolution: accepted messages: + msg63784 |
| 2008年03月17日 21:23:47 | benjamin.peterson | set | files:
+ bool_assign.patch keywords: + patch messages: + msg63782 |
| 2008年03月17日 21:06:22 | benjamin.peterson | set | nosy:
+ benjamin.peterson messages: + msg63779 |
| 2008年03月17日 21:03:53 | rhettinger | set | messages: + msg63777 |
| 2008年03月17日 20:45:28 | brett.cannon | set | messages: + msg63768 |
| 2008年03月17日 20:41:01 | rhettinger | set | nosy:
+ rhettinger messages: + msg63765 |
| 2008年03月17日 20:14:12 | brett.cannon | set | priority: release blocker -> critical |
| 2008年03月17日 19:19:17 | brett.cannon | create | |