Message238561
The following code gives a NameError:
>>> def foo(bar):
print {eval(x) for x in ['bar']}
>>> foo(2)
Traceback (most recent call last):
File "<pyshell#52>", line 1, in <module>
foo(2)
File "<pyshell#51>", line 2, in foo
print {eval(x) for x in ['bar']}
File "<pyshell#51>", line 2, in <setcomp>
print {eval(x) for x in ['bar']}
File "<string>", line 1, in <module>
NameError: name 'bar' is not defined
I've seen this kind of bug reported for Python 3.X (e.g. Issue5242), and the behavior seems to be identical (e.g. can be fixed with {eval(x) for x in ['bar'] if True or bar}), but the previously reported bug reports mention comprehension is implemented differently on 2.X and that it should not happen there, so I thought that might be of interest. |
|
Date |
User |
Action |
Args |
2015-03-19 21:31:47 | Ariel Bruner | set | recipients:
+ Ariel Bruner, tim.golden, zach.ware, steve.dower |
2015-03-19 21:31:47 | Ariel Bruner | set | messageid: <1426800707.67.0.859108792069.issue23714@psf.upfronthosting.co.za> |
2015-03-19 21:31:47 | Ariel Bruner | link | issue23714 messages |
2015-03-19 21:31:47 | Ariel Bruner | create | |
|