Pekka Klärck added the comment:
I encountered this issue because Robot Framework -- a generic Python based test
automation framework -- supports evaluating Python expressions and this issue
was reported for us:
https://github.com/robotframework/robotframework/issues/3207
--
_
Pekka Klärck added the comment:
More ways to be bitten by this strange behavior:
>>> d = {'a': 1, 'b': 2}
>>> eval('[x[k] for k in x]', {}, {'x': d})
Traceback (most recent call last):
File "", line 1, in
File "", line 1, in
File "", line 1, in
NameError: na
Terry J. Reedy added the comment:
You example is a list comprehension, but no matter. In 3.x, the value of a
comprehension is the result of calling a temporary function. Functions access
globals and nonlocals but not non-global locals of surrounding contexts. Class
locals are an example o