summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_ast.py
diff options
context:
space:
mode:
authorShantanu <12621235+hauntsaninja@users.noreply.github.com>2022-08-12 17:27:50 (GMT)
committerGitHub <noreply@github.com>2022-08-12 17:27:50 (GMT)
commitb5e3ea286289fcad12be78480daf3756e350f69f (patch)
treecbe1dd02a951509837c0136cfc78d9f0f0332931 /Lib/test/test_ast.py
parentd2373fcb498888e3faa47747a57791f0ed82c91e (diff)
downloadcpython-b5e3ea286289fcad12be78480daf3756e350f69f.zip
cpython-b5e3ea286289fcad12be78480daf3756e350f69f.tar.gz
cpython-b5e3ea286289fcad12be78480daf3756e350f69f.tar.bz2
gh-94996: Disallow parsing pos only params with feature_version < (3, 8) (GH-94997)
Diffstat (limited to 'Lib/test/test_ast.py')
-rw-r--r--Lib/test/test_ast.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py
index de34ccf..2f3e9d5 100644
--- a/Lib/test/test_ast.py
+++ b/Lib/test/test_ast.py
@@ -738,6 +738,14 @@ class AST_Tests(unittest.TestCase):
expressions[0] = f"expr = {ast.expr.__subclasses__()[0].__doc__}"
self.assertCountEqual(ast.expr.__doc__.split("\n"), expressions)
+ def test_positional_only_feature_version(self):
+ ast.parse('def foo(x, /): ...', feature_version=(3, 8))
+ ast.parse('def bar(x=1, /): ...', feature_version=(3, 8))
+ with self.assertRaises(SyntaxError):
+ ast.parse('def foo(x, /): ...', feature_version=(3, 7))
+ with self.assertRaises(SyntaxError):
+ ast.parse('def bar(x=1, /): ...', feature_version=(3, 7))
+
def test_parenthesized_with_feature_version(self):
ast.parse('with (CtxManager() as example): ...', feature_version=(3, 10))
# While advertised as a feature in Python 3.10, this was allowed starting 3.9
@@ -746,7 +754,7 @@ class AST_Tests(unittest.TestCase):
ast.parse('with (CtxManager() as example): ...', feature_version=(3, 8))
ast.parse('with CtxManager() as example: ...', feature_version=(3, 8))
- def test_issue40614_feature_version(self):
+ def test_debug_f_string_feature_version(self):
ast.parse('f"{x=}"', feature_version=(3, 8))
with self.assertRaises(SyntaxError):
ast.parse('f"{x=}"', feature_version=(3, 7))