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

SourceForge.net noreply at sourceforge.net
Wed Jul 12 07:26:45 CEST 2006


Bugs item #1520864, was opened at 2006-07-11 16:21
Message generated for change (Comment added) made by nnorwitz
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: Closed
>Resolution: Fixed
Priority: 9
Submitted By: Anthony Tuininga (atuining)
>Assigned to: Neal Norwitz (nnorwitz)
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: Neal Norwitz (nnorwitz)
Date: 2006-07-11 22:26

Message:
Logged In: YES 
user_id=33168

Awww come on, can't we change the language just to make your
life difficult? ;-)

Thanks a lot for catching this!

Committed revision 50597.


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

Comment By: Raymond Hettinger (rhettinger)
Date: 2006-07-11 19: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