[issue24800] Incorrect handling of local variables in comprehensions with exec()

R. David Murray report at bugs.python.org
Wed Aug 5 21:58:18 CEST 2015


R. David Murray added the comment:

exec is subtle.  See the explanation linked from issue 23087, which while not *exactly* on point explains the underlying problem (a comprehension is a new scope, and exec can't reach an intermediate scope the way a compiled function can).

As far as the difference from 2.7 goes, the scoping rules for comprehensions changed in python3: the variable you are concerned with is now part of the local scope.

----------
nosy: +r.david.murray
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed
superseder:  -> Exec variable not found error

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24800>
_______________________________________


More information about the Python-bugs-list mailing list