-
-
Notifications
You must be signed in to change notification settings - Fork 32k
bpo-32117: Allow tuple unpacking in return and yield statements #4509
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
Conversation
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA). Unfortunately our records indicate you have not signed the CLA. For legal reasons we need you to sign this before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. Thanks again to your contribution and we look forward to looking at it! |
CLA signed and awaiting review. |
CLA reviewed and approved. |
I'm going to close and reopen to cause Travis-CI and AppVeyor to rerun the tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming @dacut is no longer interested in this PR. Jordan Chapman, can you add the test I requested and rebase, then push?
@@ -828,6 +834,8 @@ def g(): f((yield 1)) | |||
def g(): f((yield 1), 1) | |||
def g(): f((yield from ())) | |||
def g(): f((yield from ()), 1) | |||
# Do not require parenthesis for tuple unpacking | |||
def g(): rest = 4, 5, 6; yield 1, 2, 3, *rest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add another test here to validate that this works, e.g. self.assertEqual(list(g()), [(1, 2, 3, 4, 5, 6)])
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was tempted to do self.assertEqual(*g(), (1, 2, 3, 4, 5, 6))
, but I think we're testing enough unpacking
I am. :-) I'll add that test if Jordan doesn't beat me to it. |
I've added the test to my fork (https://github.com/jChapman/cpython) and rebased, but I don't have the ability to modify this pull request, so I am unsure how to proceed. |
Also, I checked that CLA from @jChapman was received so I'll change those labels. I'll probably wait a day before merging, in case another core dev wants to have a look and/or say. |
@gvanrossum Reminder to complete merge (it has now been 4 days) |
@brettcannon What's that trello.com link? I get "Card not found". |
I touched up the news entry slightly (made sure to thank @dacut and @jChapman 😄 ). If @gvanrossum doesn't merge this by the time I do my next sweep through my Python TODO list then I will. |
@gvanrossum the Trello card is for my private board to keep track of my TODO entries; didn't realize it left a comment. :/ |
…onGH-9487) News entry clean up, added to what's new Requested by @gvanrossum in python#4509 https://bugs.python.org/issue32117
This is a fix for issue 32117:
This stems from a query on StackOverflow.
Specifically, the following syntax is allowed:
While the following result in SyntaxError:
Looking at the original commit that enabled tuple unpacking in assignment statements:
4905e80
I don't believe this difference is intentional.
https://bugs.python.org/issue32117