New submission from Evan Greensmith <evan.greensm...@gmail.com>:

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

----------
files: test_eval_comp.py
messages: 83852
nosy: evan.greensmith
severity: normal
status: open
title: Local variables unavailable for operation of list comprehension when 
using eval()
versions: Python 3.0, Python 3.1
Added file: http://bugs.python.org/file13382/test_eval_comp.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue5526>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to