diff options
author | Batuhan Taskaya <isidentical@gmail.com> | 2020-06-06 12:44:16 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-06 12:44:16 (GMT) |
commit | 68874a8502da440a1dc4746cf73262648b870aee (patch) | |
tree | 0e9a81285188e30842515122f2490b2ac197a0ce /Lib/test/test_ast.py | |
parent | 5552850f8e6ad6bf610c2633c74ed42dacc81b46 (diff) | |
download | cpython-68874a8502da440a1dc4746cf73262648b870aee.zip cpython-68874a8502da440a1dc4746cf73262648b870aee.tar.gz cpython-68874a8502da440a1dc4746cf73262648b870aee.tar.bz2 |
bpo-40870: Invalidate usage of some constants with ast.Name (GH-20649)
Diffstat (limited to 'Lib/test/test_ast.py')
-rw-r--r-- | Lib/test/test_ast.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py index a3b366e..78e4a56 100644 --- a/Lib/test/test_ast.py +++ b/Lib/test/test_ast.py @@ -668,6 +668,13 @@ class AST_Tests(unittest.TestCase): with self.assertRaises(SyntaxError): ast.parse('f"{x=}"', feature_version=(3, 7)) + def test_constant_as_name(self): + for constant in "True", "False", "None": + expr = ast.Expression(ast.Name(constant, ast.Load())) + ast.fix_missing_locations(expr) + with self.assertRaisesRegex(ValueError, f"Name node can't be used with '{constant}' constant"): + compile(expr, "<test>", "eval") + class ASTHelpers_Test(unittest.TestCase): maxDiff = None |