[issue36300] eval of comprehension cannot access local variables

2019-06-07 Thread Pekka Klärck
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 -- _

[issue36300] eval of comprehension cannot access local variables

2019-06-07 Thread Pekka Klärck
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

[issue36300] eval of comprehension cannot access local variables

2019-03-15 Thread Terry J. Reedy
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