Issue 32117: Tuple unpacking in return and yield statements (original) (raw)

Created on 2017-11-22 23:31 by dacut, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 4509 merged dacut,2017-11-22 23:39
PR 9487 merged Jordan Chapman,2018-09-22 03:48
PR 9721 merged serhiy.storchaka,2018-10-05 17:52
PR 16994 merged python-dev,2019-10-30 13:06
PR 19737 merged python-dev,2020-04-27 18:01
Messages (17)
msg306761 - (view) Author: David Cuthbert (dacut) * Date: 2017-11-22 23:31
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: https://github.com/python/cpython/commit/4905e80c3d2f6abb613d212f0313d1dfe09475dc I don't believe this difference is intentional. My GitHub repo incorporates a fix for this; I'll file a pull request momentarily.
msg306783 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-11-23 06:16
Since this changes the grammar, it should be first discussed on Python-Dev and approved by BDFL.
msg307257 - (view) Author: David Cuthbert (dacut) * Date: 2017-11-29 21:44
CLA processed, and BDFL has assented on python-dev. Serhiy, thoughts on next steps?
msg307264 - (view) Author: Henk-Jaap Wagenaar (cryvate) * Date: 2017-11-29 22:07
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.
msg307266 - (view) Author: David Cuthbert (dacut) * Date: 2017-11-29 22:20
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 "", line 1 a[1,*(4, 5, 6)] ^ SyntaxError: invalid syntax I will ask about this again on python-dev@
msg307267 - (view) Author: David Cuthbert (dacut) * Date: 2017-11-29 22:30
Oops, I wasn't looking broadly enough. This is also used in the augmented assignment statements syntax, e.g. a += 1, 2, 3
msg325327 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2018-09-14 06:09
Move to 3.8.
msg325421 - (view) Author: Jordan Chapman (Jordan Chapman) * Date: 2018-09-15 04:21
BFDL approval: https://mail.python.org/pipermail/python-dev/2017-November/150842.html
msg325459 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2018-09-15 22:34
Jordan, what's your GitHub account name? I hope you can check this out and make the changes I'm requesting on GitHub.
msg325460 - (view) Author: Jordan Chapman (Jordan Chapman) * Date: 2018-09-15 22:44
Here's my GitHub account: I'll make the changes and rebase as soon as I get home.
msg325461 - (view) Author: Jordan Chapman (Jordan Chapman) * Date: 2018-09-15 22:45
Sorry, I could have sworn that I pasted my link... https://github.com/jChapman
msg326063 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2018-09-22 01:31
New changeset fd97d1f1af910a6222ea12aec42c456b64f9aee4 by Guido van Rossum (David Cuthbert) in branch 'master': bpo-32117: Allow tuple unpacking in return and yield statements (gh-4509) https://github.com/python/cpython/commit/fd97d1f1af910a6222ea12aec42c456b64f9aee4
msg326064 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2018-09-22 01:34
Fixed by https://github.com/python/cpython/pull/4509.
msg326122 - (view) Author: miss-islington (miss-islington) Date: 2018-09-23 01:13
New changeset 8fabae3b00b2ccffd9f7bf4736734ae584ac5829 by Miss Islington (bot) (jChapman) in branch 'master': bpo-32117: Iterable unpacking in return and yield documentation (GH-9487) https://github.com/python/cpython/commit/8fabae3b00b2ccffd9f7bf4736734ae584ac5829
msg326823 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-10-01 20:25
assertEquals() is deprecated, use assertEqual() instead. This causes tests failure when run with -Werror.
msg327160 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-10-05 18:10
New changeset 4642d5f59828e774585e9895b538b24d71b9df8e by Serhiy Storchaka in branch 'master': Use assertEqual() instead of assertEquals(). (GH-9721) https://github.com/python/cpython/commit/4642d5f59828e774585e9895b538b24d71b9df8e
msg368161 - (view) Author: miss-islington (miss-islington) Date: 2020-05-05 14:50
New changeset 627f7012353411590434a7d5777ddcbcc8d97fcd by Javier Buzzi in branch 'master': bpo-32117: Updated Simpsons names in docs (GH-19737) https://github.com/python/cpython/commit/627f7012353411590434a7d5777ddcbcc8d97fcd
History
Date User Action Args
2022-04-11 14:58:54 admin set github: 76298
2020-05-05 14:50:03 miss-islington set messages: +
2020-04-27 18:01:00 python-dev set nosy: + python-devpull_requests: + <pull%5Frequest19059>
2019-10-30 13:06:24 python-dev set pull_requests: + <pull%5Frequest16520>
2018-10-05 18🔞03 serhiy.storchaka set status: open -> closedstage: patch review -> resolved
2018-10-05 18:10:02 serhiy.storchaka set messages: +
2018-10-05 17:52:10 serhiy.storchaka set stage: needs patch -> patch reviewpull_requests: + <pull%5Frequest9105>
2018-10-01 20:25:59 serhiy.storchaka set status: closed -> openmessages: + stage: resolved -> needs patch
2018-09-23 01:13:15 miss-islington set nosy: + miss-islingtonmessages: +
2018-09-22 03:48:49 Jordan Chapman set pull_requests: + <pull%5Frequest8897>
2018-09-22 01:34:30 gvanrossum set status: open -> closedresolution: fixedmessages: + stage: patch review -> resolved
2018-09-22 01:31:20 gvanrossum set messages: +
2018-09-15 22:45:15 Jordan Chapman set messages: +
2018-09-15 22:44:11 Jordan Chapman set messages: +
2018-09-15 22:34:31 gvanrossum set messages: +
2018-09-15 04:21:41 Jordan Chapman set nosy: + Jordan Chapmanmessages: +
2018-09-14 06:09:44 gvanrossum set nosy: + gvanrossummessages: + versions: + Python 3.8, - Python 3.7
2018-05-09 09:54:55 serhiy.storchaka link issue32626 superseder
2017-11-29 22:30:57 dacut set messages: +
2017-11-29 22:20:32 dacut set messages: +
2017-11-29 22:07:21 cryvate set nosy: + cryvatemessages: +
2017-11-29 21:44:55 dacut set messages: +
2017-11-23 06:17:21 serhiy.storchaka set versions: + Python 3.7, - Python 3.4, Python 3.5, Python 3.6
2017-11-23 06:16:52 serhiy.storchaka set nosy: + serhiy.storchakamessages: +
2017-11-22 23:39:10 dacut set keywords: + patchstage: patch reviewpull_requests: + <pull%5Frequest4446>
2017-11-22 23:31:49 dacut create