Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unpack list of singleton tuples not unpacking #43651

Closed
atuining mannequin opened this issue Jul 11, 2006 · 6 comments
Closed

unpack list of singleton tuples not unpacking #43651

atuining mannequin opened this issue Jul 11, 2006 · 6 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@atuining
Copy link
Mannequin

atuining mannequin commented Jul 11, 2006

BPO 1520864
Nosy @birkenfeld, @rhettinger
Files
  • lc-tuple-fix.diff
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2006-09-05.04:01:08.000>
    created_at = <Date 2006-07-11.23:21:13.000>
    labels = ['interpreter-core']
    title = 'unpack list of singleton tuples not unpacking'
    updated_at = <Date 2006-09-05.04:01:08.000>
    user = 'https://bugs.python.org/atuining'

    bugs.python.org fields:

    activity = <Date 2006-09-05.04:01:08.000>
    actor = 'nnorwitz'
    assignee = 'nnorwitz'
    closed = True
    closed_date = None
    closer = None
    components = ['Interpreter Core']
    creation = <Date 2006-07-11.23:21:13.000>
    creator = 'atuining'
    dependencies = []
    files = ['2065']
    hgrepos = []
    issue_num = 1520864
    keywords = []
    message_count = 6.0
    messages = ['29136', '29137', '29138', '29139', '29140', '29141']
    nosy_count = 5.0
    nosy_names = ['nnorwitz', 'georg.brandl', 'rhettinger', 'atuining', 'sadrejeb']
    pr_nums = []
    priority = 'critical'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue1520864'
    versions = ['Python 2.5']

    @atuining
    Copy link
    Mannequin Author

    atuining mannequin commented Jul 11, 2006

    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. :-)

    @atuining atuining mannequin closed this as completed Jul 11, 2006
    @atuining atuining mannequin assigned nnorwitz Jul 11, 2006
    @atuining atuining mannequin added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Jul 11, 2006
    @atuining atuining mannequin closed this as completed Jul 11, 2006
    @atuining atuining mannequin assigned nnorwitz Jul 11, 2006
    @atuining atuining mannequin added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Jul 11, 2006
    @rhettinger
    Copy link
    Contributor

    Logged In: YES
    user_id=80475

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

    @nnorwitz
    Copy link
    Mannequin

    nnorwitz mannequin commented Jul 12, 2006

    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.

    @sadrejeb
    Copy link
    Mannequin

    sadrejeb mannequin commented Sep 4, 2006

    Logged In: YES
    user_id=26911

    I have the impression that the bug has only been partially
    solved, i.e. in 2.5c1, singleton tuples don't get unfoled in
    list comprehensions.

    Python 2.5c1 (r25c1:51305, Sep  4 2006, 10:15:09)
    [GCC 4.1.1 20060525 (Red Hat 4.1.1-1)] on linux2
    Type "help", "copyright", "credits" or "license" for more
    information.
    >>> l = [(1,), (2,)]
    >>> print [x for x, in l]
    [(1,), (2,)]

    Same example in Python 2.4.3:

    Python 2.4.3 (#1, Jul 25 2006, 11:53:03)
    [GCC 4.1.1 20060525 (Red Hat 4.1.1-1)] on linux2
    Type "help", "copyright", "credits" or "license" for more
    information.
    >>> l = [(1,), (2,)]
    >>> print [x for x, in l]
    [1, 2]

    @birkenfeld
    Copy link
    Member

    Logged In: YES
    user_id=849994

    You're right. Attached patch fixes this.

    @nnorwitz
    Copy link
    Mannequin

    nnorwitz mannequin commented Sep 5, 2006

    Logged In: YES
    user_id=33168

    Thanks for spotting this. Let us know if you find any more
    bugs.

    Well, I'm glad Georg and I came up with the same basic patch
    (thanks Georg!). I had worked it up prior to seeing his
    version here. It's also the same fix for the for loops.

    Committed revision 51729. (2.6)
    Committed revision 51730. (2.5)

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    interpreter-core (Objects, Python, Grammar, and Parser dirs)
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants