Ticket #465 (closed defect: fixed)
fix scoping for comprehensions and generator expressions
|Reported by:||scoder||Owned by:||scoder|
The fix for the declaration analysis phase of comprehensions in
lets the comprehension variable appear in locals(). This diverges from Python's own behaviour.
The best way to fix this would be to follow Py3 and move the variable out of the surrounding scope (actually, in Py3, it becomes a generator expression, but the result is the same).
This breaks compatibility with Py2 (and also rather rare code that relies on the variable holding the last value after running the comprehension), but it's certainly worth it.