mirror of
https://github.com/python/cpython.git
synced 2025-07-19 17:25:54 +00:00
gh-94996: Disallow parsing pos only params with feature_version < (3, 8) (GH-94997)
(cherry picked from commit b5e3ea2862
)
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
This commit is contained in:
parent
7fdda1a47f
commit
4abf84602f
5 changed files with 15 additions and 6 deletions
|
@ -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))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue