summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_ast.py
diff options
context:
space:
mode:
authorShantanu <12621235+hauntsaninja@users.noreply.github.com>2022-07-18 09:20:12 (GMT)
committerGitHub <noreply@github.com>2022-07-18 09:20:12 (GMT)
commitae0be5a53bb4caee3de4888341addd9c94133f2d (patch)
treeb6dbf5b251e3ef14eeb30da142e14fa22dbebb60 /Lib/test/test_ast.py
parent97b4121f9373a1b5312b90ac00eae9960deacfdb (diff)
downloadcpython-ae0be5a53bb4caee3de4888341addd9c94133f2d.zip
cpython-ae0be5a53bb4caee3de4888341addd9c94133f2d.tar.gz
cpython-ae0be5a53bb4caee3de4888341addd9c94133f2d.tar.bz2
gh-94947: Disallow parsing walrus with feature_version < (3, 8) (#94948)
* gh-94947: Disallow parsing walrus with feature_version < (3, 8) * oops, commit the parser * 📜🤖 Added by blurb_it. Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Diffstat (limited to 'Lib/test/test_ast.py')
-rw-r--r--Lib/test/test_ast.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py
index 2258924..5d7e441 100644
--- a/Lib/test/test_ast.py
+++ b/Lib/test/test_ast.py
@@ -743,6 +743,11 @@ class AST_Tests(unittest.TestCase):
with self.assertRaises(SyntaxError):
ast.parse('f"{x=}"', feature_version=(3, 7))
+ def test_assignment_expression_feature_version(self):
+ ast.parse('(x := 0)', feature_version=(3, 8))
+ with self.assertRaises(SyntaxError):
+ ast.parse('(x := 0)', feature_version=(3, 7))
+
def test_constant_as_name(self):
for constant in "True", "False", "None":
expr = ast.Expression(ast.Name(constant, ast.Load()))