[Python-Dev] Allow tuple unpacking in return and yield statements
ncoghlan at gmail.com
Sat Nov 25 23:55:26 EST 2017
On 26 November 2017 at 09:22, Terry Reedy <tjreedy at udel.edu> wrote:
> Since return and yield are often the first half of a cross-namespace
> assignment, requiring the () is a bit surprising. Perhaps someone else has
> a good reason for the difference.
These kinds of discrepancies tend to arise because there are a few
different grammar nodes for "comma separated sequence of expressions",
which makes it possible to miss some when enhancing the tuple syntax.
Refactoring the grammar to eliminate the duplication isn't especially
easy, and we don't change the syntax all that often, so it makes
sense to treat cases like this one as bugs in the implementation of
the original syntax change (except that the "don't change the Grammar
in maintenance releases" guideline means they still need to be handled
as new features when it comes to fixing them).
P.S. That said, I do wonder if it might be feasible to write a
"Grammar consistency check" test that ensured the known duplicate
nodes at least have consistent definitions, such that missing one in a
syntax update will cause an automated test failure. Unfortunately, the
nodes typically haven't been combined because they have some
*intentional* differences in exactly what they allow, so I also
suspect that this is easier said than done.
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-Dev