New submission from Martin Hosken <martin_hos...@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 <rep...@bugs.python.org>
<https://bugs.python.org/issue36300>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to