bpo-32117: Allow tuple unpacking in return and yield statements by dacut · Pull Request #4509 · python/cpython (original) (raw)

This is a fix for issue 32117:

This stems from a query on StackOverflow.

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.

https://bugs.python.org/issue32117