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 evan.greensmith
Recipients evan.greensmith
Date 2009-03-20.03:59:25
SpamBayes Score 3.193057e-12
Marked as misclassified No
Message-id <1237521589.9.0.0850513364759.issue5526@psf.upfronthosting.co.za>
In-reply-to
Content
In python 3.0 and 3.1, attempting to access a local variable from within
a list comprehension in a string passed to eval() causes a NameError. 
Doesn't seem to be a problem in python 2.6

I have attempted to run the attached test cases (test_eval_comp.py)
using the following builds of python:

Python 2.6.1 (r261:67517, Dec  4 2008, 16:51:00) [MSC v.1500 32 bit
(Intel)] on win32

Python 3.0.1 (r301:69561, Feb 13 2009, 20:04:18) [MSC v.1500 32 bit
(Intel)] on win32

Python 3.1a1 (r31a1:70244, Mar  8 2009, 18:15:03) [MSC v.1500 32 bit
(Intel)] on win32

All tests passed with Python 2.6.1.  The following five tests failed
with Python 3.0.1 and 3.1a1

EvalWithComprehensionTestCase.test_local_var
    NameError: global name 'value' is not defined
EvalWithComprehensionTestCase.test_function_arg
    NameError: global name 'value' is not defined
EvalWithComprehensionTestCase.test_self_attrib
    NameError: global name 'self' is not defined
ExampleFromDocsTestCase.test_local_var
    NameError: global name 'vec1' is not defined
NestedComprehensionExampleFromDocsTestCase.test_local_var
    NameError: global name 'mat' is not defined
History
Date User Action Args
2009-03-20 03:59:50evan.greensmithsetrecipients: + evan.greensmith
2009-03-20 03:59:49evan.greensmithsetmessageid: <1237521589.9.0.0850513364759.issue5526@psf.upfronthosting.co.za>
2009-03-20 03:59:27evan.greensmithlinkissue5526 messages
2009-03-20 03:59:26evan.greensmithcreate