[Python-bugs-list] [ python-Bugs-471928 ] global made w/nested list comprehensions

noreply@sourceforge.net noreply@sourceforge.net
Tue, 16 Oct 2001 18:35:14 -0700


Bugs item #471928, was opened at 2001-10-16 18:35
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=471928&group_id=5470

Category: Python Interpreter Core
Group: Python 2.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Neal Norwitz (nnorwitz)
Assigned to: Nobody/Anonymous (nobody)
Summary: global made w/nested list comprehensions

Initial Comment:
This bug affects Python 2.1.1 & 2.2a4+.

In nested list comprehension code like this:

        [bad for s in 'a b' for bad in s.split()]

the variable bad becomes a global, but it should be
local variable.

The attached file shows the disassembled byte code,
along with a test case.

The original source of the error was found from
cgi.py:209
in the standard library:

    pairs = [s2 for s1 in qs.split('&') for s2 in
s1.split(';')]

Neal


----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=471928&group_id=5470