mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
gh-94949: Disallow parsing parenthesised ctx mgr with old feature_version (GH-94950)
* gh-94949: Disallow parsing parenthesised ctx manager with old feature_version
* 📜🤖 Added by blurb_it.
* Allow it with feature_version=(3, 9) as well
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
(cherry picked from commit 0daba82221
)
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
This commit is contained in:
parent
be84daf52a
commit
7733aa048e
4 changed files with 11 additions and 2 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_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
|
||||
ast.parse('with (CtxManager() as example): ...', feature_version=(3, 9))
|
||||
with self.assertRaises(SyntaxError):
|
||||
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):
|
||||
ast.parse('f"{x=}"', feature_version=(3, 8))
|
||||
with self.assertRaises(SyntaxError):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue