Skip to content

Tuple unpacking in return and yield statements #76298

Closed

Description

@dacut
mannequin
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']

    Activity

    1. dacut commented on Nov 22, 2017

      dacutmannequin
      MannequinAuthor

      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.

    2. added
      interpreter-core(Objects, Python, Grammar, and Parser dirs)
      type-bugAn unexpected behavior, bug, or error
      on Nov 22, 2017
    3. serhiy-storchaka commented on Nov 23, 2017

      @serhiy-storchaka
      Member

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

    4. dacut commented on Nov 29, 2017

      dacutmannequin
      MannequinAuthor

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

    5. Cryvate commented on Nov 29, 2017

      Cryvatemannequin
      Mannequin

      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.

    6. dacut commented on Nov 29, 2017

      dacutmannequin
      MannequinAuthor

      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@

    7. dacut commented on Nov 29, 2017

      dacutmannequin
      MannequinAuthor

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

    8. gvanrossum commented on Sep 14, 2018

      @gvanrossum
      Member

      Move to 3.8.

    9. jChapman commented on Sep 15, 2018

      jChapmanmannequin
      Mannequin
    10. gvanrossum commented on Sep 15, 2018

      @gvanrossum
      Member

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

    11. jChapman commented on Sep 15, 2018

      jChapmanmannequin
      Mannequin

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

    12. jChapman commented on Sep 15, 2018

      jChapmanmannequin
      Mannequin

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

    13. gvanrossum commented on Sep 22, 2018

      @gvanrossum
      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

    14. gvanrossum commented on Sep 22, 2018

      @gvanrossum
      Member

      Fixed by #4509.

    15. miss-islington commented on Sep 23, 2018

      @miss-islington
      Contributor

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

    16. serhiy-storchaka commented on Oct 1, 2018

      @serhiy-storchaka
      Member

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

    17. serhiy-storchaka commented on Oct 5, 2018

      @serhiy-storchaka
      Member

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

    18. miss-islington commented on May 5, 2020

      @miss-islington
      Contributor

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

    19. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.8 (EOL)end of lifeinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions