Ticket #465 (closed defect: fixed)
fix scoping for comprehensions and generator expressions
| Reported by: | scoder | Owned by: | scoder |
|---|---|---|---|
| Priority: | minor | Milestone: | 0.13 |
| Component: | Python Semantics | Keywords: | |
| Cc: |
Description
The fix for the declaration analysis phase of comprehensions in
http://hg.cython.org/cython-devel/rev/2646e35eeb7f
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.
Change History
Note: See
TracTickets for help on using
tickets.
