Issue3936
Created on 2008-09-22 21:52 by terry.reedy, last changed 2022-04-11 14:56 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| fix_warning_after_import.patch | benjamin.peterson, 2008-09-23 22:22 | |||
| after_review.patch | benjamin.peterson, 2008-09-25 02:15 | |||
| Messages (8) | |||
|---|---|---|---|
| msg73600 - (view) | Author: Terry J. Reedy (terry.reedy) * ![]() |
Date: 2008-09-22 21:52 | |
Copied from c.l.p post by F. Lundh I have no idea if this has implications for warnings in 2.6 ------------------------ > >>> from sympy.mpmath import specfun > >>> > > So what could be suppressing the warning? [about 'as' becoming a keyword, when assigned to] a bug in Python 2.5, it seems: > more f1.py as = 1 as = 2 as = 3 > python f1.py f1.py:1: Warning: 'as' will become a reserved keyword in Python 2.6 f1.py:2: Warning: 'as' will become a reserved keyword in Python 2.6 f1.py:3: Warning: 'as' will become a reserved keyword in Python 2.6 > more f2.py as = 1 import os as = 3 > python f2.py f2.py:1: Warning: 'as' will become a reserved keyword in Python 2.6 A quick look in parsetok.c reveals that it sets a "handling_import" flag when it stumbles upon an "import" statement, a flag that's later used to suppress the warning message. The bug is that the flag isn't reset until the parser sees an ENDMARKER token (end of file), instead of when it sees the next NEWLINE token. (if someone wants to submit this to bugs.python.org, be my guest) |
|||
| msg73655 - (view) | Author: Koen van de Sande (koen) | Date: 2008-09-23 19:16 | |
I was wondering why I didn't have any warnings in my code in 2.5, when it started failing with errors on import in 2.6. Now I know. |
|||
| msg73671 - (view) | Author: Benjamin Peterson (benjamin.peterson) * ![]() |
Date: 2008-09-23 22:22 | |
Attaching patch and test. |
|||
| msg73679 - (view) | Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * ![]() |
Date: 2008-09-23 23:49 | |
I would be more comfortable if "started = 1" was also executed in the
NEWLINE case. I'm not sure to understand the exact use of its value.
And do you think if it's possible to add the type==SEMICOLON case?
This would properly show the warning for:
import sys; as = 3 # on the same line
There are still some far-fetched constructs that do not warn, like:
import sys as as
but they are probably not worth the trouble.
|
|||
| msg73767 - (view) | Author: Benjamin Peterson (benjamin.peterson) * ![]() |
Date: 2008-09-25 02:15 | |
You're right; I should put it within the started block. Actually, no import cases are currently handled by the warning to avoid conflicting with "import foo as bar". This isn't really an issue, though because using the module name "as.attribute" will give a warning. If we were going to do this again, I would implement the warning in AST generation, but it's far too late for that. |
|||
| msg73772 - (view) | Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * ![]() |
Date: 2008-09-25 07:46 | |
Patch is good to me. Actually 2.5 is not in "Release Candidate" stage, do we really need formal review? |
|||
| msg73778 - (view) | Author: Benjamin Peterson (benjamin.peterson) * ![]() |
Date: 2008-09-25 11:52 | |
On Thu, Sep 25, 2008 at 2:46 AM, Amaury Forgeot d'Arc <report@bugs.python.org> wrote: > > Amaury Forgeot d'Arc <amauryfa@gmail.com> added the comment: > > Patch is good to me. > > Actually 2.5 is not in "Release Candidate" stage, do we really need > formal review? Well, it certainly can't hurt. :) > > ---------- > keywords: -needs review > > _______________________________________ > Python tracker <report@bugs.python.org> > <http://bugs.python.org/issue3936> > _______________________________________ > |
|||
| msg73813 - (view) | Author: Benjamin Peterson (benjamin.peterson) * ![]() |
Date: 2008-09-25 20:46 | |
Fixed in r66618. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:56:39 | admin | set | github: 48186 |
| 2008-09-25 20:46:41 | benjamin.peterson | set | status: open -> closed resolution: fixed messages: + msg73813 |
| 2008-09-25 11:52:56 | benjamin.peterson | set | assignee: benjamin.peterson |
| 2008-09-25 11:52:37 | benjamin.peterson | set | messages: + msg73778 |
| 2008-09-25 07:46:22 | amaury.forgeotdarc | set | keywords:
- needs review messages: + msg73772 |
| 2008-09-25 02:15:45 | benjamin.peterson | set | files:
+ after_review.patch messages: + msg73767 |
| 2008-09-23 23:49:25 | amaury.forgeotdarc | set | nosy:
+ amaury.forgeotdarc messages: + msg73679 |
| 2008-09-23 22:22:26 | benjamin.peterson | set | priority: high keywords: + needs review, patch messages: + msg73671 files: + fix_warning_after_import.patch nosy: + benjamin.peterson |
| 2008-09-23 19:16:21 | koen | set | nosy:
+ koen messages: + msg73655 |
| 2008-09-22 21:52:21 | terry.reedy | create | |
