]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.7] bpo-36541: lib2to3: Support named assignment expressions (GH-12702) (GH-19317)
authorTim Hatch <tim@timhatch.com>
Fri, 3 Apr 2020 19:14:15 +0000 (12:14 -0700)
committerGitHub <noreply@github.com>
Fri, 3 Apr 2020 19:14:15 +0000 (12:14 -0700)
commit96c5f5a3a3fabf43e8114d0dbc30bed409da1ba6
tree971453a0ae5a1a658ca78d35ef8f2357ced18ad0
parentd19162fe5b2aba48a94278baa0f569fc42932072
[3.7] bpo-36541: lib2to3: Support named assignment expressions (GH-12702) (GH-19317)

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]