gh-96587: Raise SyntaxError for PEP654 on older feature_version (#96588)

This commit is contained in:
Nikita Sobolev 2022-09-05 19:54:09 +03:00 committed by GitHub
parent a9d58feccf
commit 2c7d2e8d46
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 2 deletions

View file

@ -771,6 +771,15 @@ class AST_Tests(unittest.TestCase):
with self.assertRaises(SyntaxError):
ast.parse('(x := 0)', feature_version=(3, 7))
def test_exception_groups_feature_version(self):
code = dedent('''
try: ...
except* Exception: ...
''')
ast.parse(code)
with self.assertRaises(SyntaxError):
ast.parse(code, feature_version=(3, 10))
def test_invalid_major_feature_version(self):
with self.assertRaises(ValueError):
ast.parse('pass', feature_version=(2, 7))