[issue36300] eval of generator expressions cannot access local variables
Martin Hosken
report at bugs.python.org
Fri Mar 15 06:44:12 EDT 2019
New submission from Martin Hosken <martin_hosken at sil.org>:
The following code fails:
>>> lcls = {'w': 100}
>>> eval('[w for x in ("hello", "world")]', None, lcls)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 1, in <module>
File "<string>", line 1, in <listcomp>
NameError: name 'w' is not defined
>>> eval('[w, w, w]', None, lcls)
[100, 100, 100]
whereas in python2 it succeeds
>>> lcls = {'w': 100}
>>> eval('[w for x in ("hello", "world")]', None, lcls)
[100, 100]
----------
messages: 337980
nosy: Martin Hosken
priority: normal
severity: normal
status: open
title: eval of generator expressions cannot access local variables
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36300>
_______________________________________
More information about the Python-bugs-list
mailing list