Python tuple unpacking in return statement
I suspect this is an accident, based on the comments from this commit for Python 3.2.
That commit enabled the assignment expression to take a testlist_star_expr
production (what allows the unparenthesized unpacking), but left the return statement taking a testlist
production. I suspect the commit just missed this (and possibly other locations, but I'm focusing on the return_stmt
production for now).
I went ahead and modified the Python Grammar/Grammar file to allow this. All of the tests continue to pass, including those in the test_grammar.py
file (but this doesn't seem terribly exhaustive).
If you're curious, this is the change I made. Feel free to clone or download my fork.
UPDATE: I've submitted a bpo issue and a pull request for the return (and yield) unpacking.