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

noreply@sourceforge.net noreply@sourceforge.net
Tue, 16 Oct 2001 23:06:44 -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: Thomas Wouters (twouters)
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


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

>Comment By: Guido van Rossum (gvanrossum)
Date: 2001-10-16 23:06

Message:
Logged In: YES 
user_id=6380

Good catch! I don't know the list comprehension code
generation, and I don't know who does. Maybe Thomas Wouters?

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

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