[New-bugs-announce] [issue42354] Tuple unpacking with * causes SyntaxError in with ... as ...

Trey Hunner report at bugs.python.org
Fri Nov 13 15:00:30 EST 2020


New submission from Trey Hunner <trey at truthful.technology>:

The below code worked on Python 3.5, 3.6, 3.7, and 3.8, but it now crashes on Python 3.9.


from contextlib import contextmanager


@contextmanager
def open_files(names):
    yield names  # This would actually return file objects


with open_files(['file1.txt', 'file2.txt']) as (first, *rest):
    print(first, rest)


The error shown is:

    with open_files(['file1.txt', 'file2.txt']) as (first, *rest):
                                                                 ^
SyntaxError: invalid syntax

----------
messages: 380932
nosy: trey
priority: normal
severity: normal
status: open
title: Tuple unpacking with * causes SyntaxError in with ... as ...
type: behavior
versions: Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42354>
_______________________________________


More information about the New-bugs-announce mailing list