summaryrefslogtreecommitdiffstats
path: root/Lib/lib2to3/pgen2/tokenize.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2020-04-02 23:03:09 (GMT)
committerGitHub <noreply@github.com>2020-04-02 23:03:09 (GMT)
commit1098671e4e5ec1513247f05598158eaa3428c5be (patch)
treeda5e4cf1bd2523098e55386670ff28b1e4158ac2 /Lib/lib2to3/pgen2/tokenize.py
parentb7345c24a4d962e2adbafc86e4af77de9e3ef09e (diff)
downloadcpython-1098671e4e5ec1513247f05598158eaa3428c5be.zip
cpython-1098671e4e5ec1513247f05598158eaa3428c5be.tar.gz
cpython-1098671e4e5ec1513247f05598158eaa3428c5be.tar.bz2
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>
Diffstat (limited to 'Lib/lib2to3/pgen2/tokenize.py')
-rw-r--r--Lib/lib2to3/pgen2/tokenize.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/Lib/lib2to3/pgen2/tokenize.py b/Lib/lib2to3/pgen2/tokenize.py
index 7924ff3..0e2685d 100644
--- a/Lib/lib2to3/pgen2/tokenize.py
+++ b/Lib/lib2to3/pgen2/tokenize.py
@@ -93,7 +93,7 @@ Operator = group(r"\*\*=?", r">>=?", r"<<=?", r"<>", r"!=",
r"~")
Bracket = '[][(){}]'
-Special = group(r'\r?\n', r'[:;.,`@]')
+Special = group(r'\r?\n', r':=', r'[:;.,`@]')
Funny = group(Operator, Bracket, Special)
PlainToken = group(Number, Funny, String, Name)