[ python-Bugs-1520864 ] unpack list of singleton tuples not unpacking

SourceForge.net noreply at sourceforge.net
Wed Jul 12 04:38:08 CEST 2006


Bugs item #1520864, was opened at 2006-07-11 18:21
Message generated for change (Settings changed) made by rhettinger
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1520864&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: Python 2.5
Status: Open
Resolution: None
>Priority: 9
Submitted By: Anthony Tuininga (atuining)
Assigned to: Nobody/Anonymous (nobody)
Summary: unpack list of singleton tuples not unpacking

Initial Comment:
The following code works differently in Python 2.5 than
Python 2.4:

x = [(1,), (2,), (3,)]
for y, in x:
    print y

In Python 2.4, this code produces the following:
1
2
3

In Python 2.5, this code produces the following:
(1,)
(2,)
(3,)

Interestingly enough the following code:

x = (1,)
y, = x
print y

produces the output
1

in both Python 2.4 and Python 2.5. I'm thinking this is
not intentional. :-)

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

>Comment By: Raymond Hettinger (rhettinger)
Date: 2006-07-11 21:38

Message:
Logged In: YES 
user_id=80475

Ouch.  This is bad.  The disassembly shows that the compiler
 isn't generating the unpack_sequence opcode.

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

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


More information about the Python-bugs-list mailing list