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

Tuple unpacking in return and yield statements #76298

Closed
dacut mannequin opened this issue Nov 22, 2017 · 17 comments
Closed

Tuple unpacking in return and yield statements #76298

dacut mannequin opened this issue Nov 22, 2017 · 17 comments
Labels
3.8 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@dacut
Copy link
Mannequin

dacut mannequin commented Nov 22, 2017

BPO 32117
Nosy @gvanrossum, @serhiy-storchaka, @cryvate, @dacut, @miss-islington, @jChapman
PRs
  • bpo-32117: Allow tuple unpacking in return and yield statements #4509
  • bpo-32117: Iterable unpacking in return and yield documentation #9487
  • Use assertEqual() instead of assertEquals(). #9721
  • bpo-38641: Add support of starred expressions in return/yield to lib2to3 #16994
  • bpo-32117: Updated Simpsons names in docs #19737
  • 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 2018-10-05.18:18:03.512>
    created_at = <Date 2017-11-22.23:31:49.357>
    labels = ['interpreter-core', 'type-bug', '3.8']
    title = 'Tuple unpacking in return and yield statements'
    updated_at = <Date 2020-05-05.14:50:03.820>
    user = 'https://github.com/dacut'

    bugs.python.org fields:

    activity = <Date 2020-05-05.14:50:03.820>
    actor = 'miss-islington'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-10-05.18:18:03.512>
    closer = 'serhiy.storchaka'
    components = ['Interpreter Core']
    creation = <Date 2017-11-22.23:31:49.357>
    creator = 'dacut'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 32117
    keywords = ['patch']
    message_count = 17.0
    messages = ['306761', '306783', '307257', '307264', '307266', '307267', '325327', '325421', '325459', '325460', '325461', '326063', '326064', '326122', '326823', '327160', '368161']
    nosy_count = 7.0
    nosy_names = ['gvanrossum', 'python-dev', 'serhiy.storchaka', 'cryvate', 'dacut', 'miss-islington', 'Jordan Chapman']
    pr_nums = ['4509', '9487', '9721', '16994', '19737']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue32117'
    versions = ['Python 3.8']

    @dacut
    Copy link
    Mannequin Author

    dacut mannequin commented Nov 22, 2017

    This stems from a query on StackOverflow: https://stackoverflow.com/questions/47272460/python-tuple-unpacking-in-return-statement/

    Specifically, the following syntax is allowed:
    def f():
    rest = (4, 5, 6)
    t = 1, 2, 3, *rest

    While the following result in SyntaxError:
    def g():
    rest = (4, 5, 6)
    return 1, 2, 3, *rest

    def h():
        rest = (4, 5, 6)
        yield 1, 2, 3, *rest

    Looking at the original commit that enabled tuple unpacking in assignment statements:
    4905e80

    I don't believe this difference is intentional.

    My GitHub repo incorporates a fix for this; I'll file a pull request momentarily.

    @dacut dacut mannequin added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Nov 22, 2017
    @serhiy-storchaka
    Copy link
    Member

    Since this changes the grammar, it should be first discussed on Python-Dev and approved by BDFL.

    @serhiy-storchaka serhiy-storchaka added the 3.7 (EOL) end of life label Nov 23, 2017
    @dacut
    Copy link
    Mannequin Author

    dacut mannequin commented Nov 29, 2017

    CLA processed, and BDFL has assented on python-dev. Serhiy, thoughts on next steps?

    @Cryvate
    Copy link
    Mannequin

    Cryvate mannequin commented Nov 29, 2017

    I think the language spec needs updating as well? In particular in

    https://docs.python.org/3/reference/simple_stmts.html#the-return-statement

    it seems expression_list should be replaced by starred_list.

    @dacut
    Copy link
    Mannequin Author

    dacut mannequin commented Nov 29, 2017

    Hm... that leaves the only production for expression_list as:
    subscription ::= primary "[" expression_list "]"

    And I'm not sure that this shouldn't also be replaced by starred_list. It's not accepted today, though:

    In [6]: a[1,(4, 5, 6)]
    File "<ipython-input-6-ba56159162e9>", line 1
    a[1,
    (4, 5, 6)]
    ^
    SyntaxError: invalid syntax

    I will ask about this again on python-dev@

    @dacut
    Copy link
    Mannequin Author

    dacut mannequin commented Nov 29, 2017

    Oops, I wasn't looking broadly enough. This is also used in the augmented assignment statements syntax, e.g. a += 1, 2, 3

    @gvanrossum
    Copy link
    Member

    Move to 3.8.

    @gvanrossum gvanrossum added 3.8 only security fixes and removed 3.7 (EOL) end of life labels Sep 14, 2018
    @jChapman
    Copy link
    Mannequin

    jChapman mannequin commented Sep 15, 2018

    @gvanrossum
    Copy link
    Member

    Jordan, what's your GitHub account name? I hope you can check this out and make the changes I'm requesting on GitHub.

    @jChapman
    Copy link
    Mannequin

    jChapman mannequin commented Sep 15, 2018

    Here's my GitHub account: I'll make the changes and rebase as soon as I get home.

    @jChapman
    Copy link
    Mannequin

    jChapman mannequin commented Sep 15, 2018

    Sorry, I could have sworn that I pasted my link... https://github.com/jChapman

    @gvanrossum
    Copy link
    Member

    New changeset fd97d1f by Guido van Rossum (David Cuthbert) in branch 'master':
    bpo-32117: Allow tuple unpacking in return and yield statements (gh-4509)
    fd97d1f

    @gvanrossum
    Copy link
    Member

    Fixed by #4509.

    @miss-islington
    Copy link
    Contributor

    New changeset 8fabae3 by Miss Islington (bot) (jChapman) in branch 'master':
    bpo-32117: Iterable unpacking in return and yield documentation (GH-9487)
    8fabae3

    @serhiy-storchaka
    Copy link
    Member

    assertEquals() is deprecated, use assertEqual() instead. This causes tests failure when run with -Werror.

    @serhiy-storchaka
    Copy link
    Member

    New changeset 4642d5f by Serhiy Storchaka in branch 'master':
    Use assertEqual() instead of assertEquals(). (GH-9721)
    4642d5f

    @miss-islington
    Copy link
    Contributor

    New changeset 627f701 by Javier Buzzi in branch 'master':
    bpo-32117: Updated Simpsons names in docs (GH-19737)
    627f701

    @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
    3.8 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants