[issue35273] 'eval' in generator expression behave different in dict from list

2018-11-21 Thread Raymond Hettinger
Change by Raymond Hettinger : -- stage: -> resolved status: open -> closed ___ Python tracker ___ ___ Python-bugs-list mailing

[issue35273] 'eval' in generator expression behave different in dict from list

2018-11-20 Thread Josh Rosenberg
Josh Rosenberg added the comment: The "bug" is the expected behavior for 2.7, as previously noted, and does not exist on Python 3 (where list comprehensions follow the same rules as generator expressions for scoping), where NameErrors are raised consistently. -- nosy: +josh.r

[issue35273] 'eval' in generator expression behave different in dict from list

2018-11-19 Thread Windson Yang
Windson Yang added the comment: I get NameError for both versions in both 3.4.4, 3.5.2, 3.6.4, 3.7.1 -- nosy: +Windson Yang ___ Python tracker ___

[issue35273] 'eval' in generator expression behave different in dict from list

2018-11-18 Thread Peter Otten
Peter Otten <__pete...@web.de> added the comment: You probably saw this is in Python 2.7 where it is the expected behaviour. All versions of Python 3 should produce the NameError. -- nosy: +peter.otten versions: +Python 3.6 -Python 2.7 ___ Python

[issue35273] 'eval' in generator expression behave different in dict from list

2018-11-18 Thread yesheng
yesheng <13611358...@139.com> added the comment: I tried again, and could not reproduce on 3.6.7, latest update: For 3.6.7: Both yyy() and zzz() got NameError For 2.7.9 (default, Dec 10 2014, 12:24:55) [MSC v.1500 32 bit (Intel)] yyy() got ['abc', 'abd'] zzz() got NameError 2.7.11

[issue35273] 'eval' in generator expression behave different in dict from list

2018-11-18 Thread Raymond Hettinger
Raymond Hettinger added the comment: I get NameError for both versions in both 3.6.5 and 3.7.1. -- nosy: +rhettinger ___ Python tracker ___

[issue35273] 'eval' in generator expression behave different in dict from list

2018-11-18 Thread yesheng
New submission from yesheng <13611358...@139.com>: def yyy(): a, b = 'abc', 'abd' print([eval(i) for i in ('a', 'b')]) def zzz(): a, b = 'abc', 'abd' print({i: eval(i) for i in ('a', 'b')}) yyy() # ok zzz() # NameError: name 'a' is not defined, however in yyy() it is ok