[New-bugs-announce] [issue41506] Inclusion or documentation of extended with syntax in 3.9

Aaron Meurer report at bugs.python.org
Fri Aug 7 21:32:00 EDT 2020


New submission from Aaron Meurer <asmeurer at gmail.com>:

This discussion started at https://github.com/python/cpython/pull/19503 (actually on Twitter https://twitter.com/asmeurer/status/1289304407696261120), but Guido asked me to move it bpo.

Alongside the implementation of Python 3.9's new PEG parser, a new syntax feature has been added, which is the ability to use parentheses in with statements, like

    with (open('a') as f1,
        open('b') as f2):
        ...

This is an error in lower versions of Python (or an error about tuple not having __enter__ if the "as" parts are omitted). 

This new feature is not documented in the "What's new in Python 3.9" document https://docs.python.org/3.9/whatsnew/3.9.html.

It also apparently goes against PEP 627 https://www.python.org/dev/peps/pep-0617/, which says (in bold), "no new Python Grammar addition will be added that requires the PEG parser".

Note that this feature does indeed rely on the PEG parser, and it stops working if you use python -X oldparser or PYTHONOLDPARSER=1.

I think this feature should either

1. be removed from 3.9 and held until 3.10, or
2. be documented properly, including in the document for the "with" statement and the "what's new" document. Also the PEP should be updated if this option is chosen.

Others have stated opinions about this on the issue or on Twitter, but I'll let them repeat them here rather than trying to summarize.

----------
messages: 375029
nosy: asmeurer
priority: normal
pull_requests: 20921
severity: normal
status: open
title: Inclusion or documentation of extended with syntax in 3.9
versions: Python 3.9

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


More information about the New-bugs-announce mailing list