]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
lib2to3: Support named assignment expressions (GH-12702)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 2 Apr 2020 23:03:09 +0000 (16:03 -0700)
committerGitHub <noreply@github.com>
Thu, 2 Apr 2020 23:03:09 +0000 (16:03 -0700)
commit1098671e4e5ec1513247f05598158eaa3428c5be
treeda5e4cf1bd2523098e55386670ff28b1e4158ac2
parentb7345c24a4d962e2adbafc86e4af77de9e3ef09e
lib2to3: Support named assignment expressions (GH-12702)

There are two copies of the grammar -- the one used by Python itself as
Grammar/Grammar, and the one used by lib2to3 which has necessarily diverged at
Lib/lib2to3/Grammar.txt because it needs to support older syntax an we want it
to be reasonable stable to avoid requiring fixer rewrites.

This brings suport for syntax like `if x:= foo():` to match what the live
Python grammar does.

This should've been added at the time of the walrus operator itself, but lib2to3 being
independent is often overlooked.  So we do consider this a bugfix rather than enhancement.
(cherry picked from commit 3c3aa4516c70753de06bb142b6793d01330fcf0f)

Co-authored-by: Tim Hatch <tim@timhatch.com>
Lib/lib2to3/Grammar.txt
Lib/lib2to3/pgen2/grammar.py
Lib/lib2to3/pgen2/token.py
Lib/lib2to3/pgen2/tokenize.py
Lib/lib2to3/tests/test_parser.py
Misc/NEWS.d/next/Library/2019-06-18-19-38-27.bpo-36541.XI8mi1.rst [new file with mode: 0644]