This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Ariel Bruner
Recipients Ariel Bruner, steve.dower, tim.golden, zach.ware
Date 2015-03-19.21:31:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1426800707.67.0.859108792069.issue23714@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2015-03-19 21:31:47Ariel Brunersetrecipients: + Ariel Bruner, tim.golden, zach.ware, steve.dower
2015-03-19 21:31:47Ariel Brunersetmessageid: <1426800707.67.0.859108792069.issue23714@psf.upfronthosting.co.za>
2015-03-19 21:31:47Ariel Brunerlinkissue23714 messages
2015-03-19 21:31:47Ariel Brunercreate