New submission from Alex <bojenko.a...@gmail.com>:
Builtin eval() function raises NameError on a valid expression: --- example of bug on Python 3.4 Python 3.4.5 (default, May 29 2017, 15:17:55) [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> x = [1,2,3] >>> [x for i in x] [[1, 2, 3], [1, 2, 3], [1, 2, 3]] >>> eval('[x for i in x]', {}, dict(x=x)) 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 'x' is not defined --- example on Python 2.7 (no bug) Python 2.7.5 (default, May 3 2017, 07:55:04) [GCC 4.8.5 20150623 (Red Hat 4.8.5-14)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> x = [1,2,3] >>> [x for i in x] [[1, 2, 3], [1, 2, 3], [1, 2, 3]] >>> eval('[x for i in x]', {}, dict(x=x)) [[1, 2, 3], [1, 2, 3], [1, 2, 3]] --- Bug reproduced on: - Windows 7: Python 3.4, 3.7 - Red Hat Enterprise Linux Server: Python 3.4 Works without errors on: - Windows 7: Python 2.7 - Red Hat Enterprise Linux Server: Python 2.7 ---------- components: Interpreter Core messages: 323965 nosy: alexb priority: normal severity: normal status: open title: eval() raises NameError: name '...' is not defined versions: Python 3.4, Python 3.7 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue34483> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com