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.

classification
Title: No deprecation warning for list comprehension leak conflict
Type: behavior Stage:
Components: Interpreter Core Versions: Python 2.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: mrbax, terry.reedy
Priority: normal Keywords:

Created on 2009-07-26 17:25 by mrbax, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg90952 - (view) Author: Michael R Bax (mrbax) Date: 2009-07-26 17:25
PEP 289 states that "Python 2.4 and beyond should issue a deprecation 
warning if a list comprehension's loop variable has the same name as a 
variable used in the immediately surrounding scope".  But no warning is 
shown when running
    for x in [ 0 ]: print [ x for x in [ 1 ] ]
in Python 2.5.2 (at least).
msg91150 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2009-07-31 20:26
2.5 is closed to fixes other than security fixes.
So this needs to be checked with the latest 2.6.

The implementation of new features does not always exactly follow the
PEP. So if there is also no warning in 2.6, the question remains whether
accident or intention. Perhaps it was decided that the warning was too
difficult or that it would make too much noise because some people were
doing this intentionally and would not want the warning, whereas few
people accidentally do the sort of thing your example does.

If this is true, as I sort of suspect, the PEP should be revised not to
mislead.
msg112690 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2010-08-03 21:31
Not an issue in 3.x.
History
Date User Action Args
2022-04-11 14:56:51adminsetgithub: 50829
2010-08-03 21:31:39terry.reedysetstatus: open -> closed
resolution: not a bug
messages: + msg112690
2009-07-31 20:26:16terry.reedysetnosy: + terry.reedy
messages: + msg91150
2009-07-26 17:25:01mrbaxcreate