summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorShantanu <12621235+hauntsaninja@users.noreply.github.com>2022-07-18 21:10:49 (GMT)
committerGitHub <noreply@github.com>2022-07-18 21:10:49 (GMT)
commit0daba822212cd5d6c63384a27f390f0945330c2b (patch)
tree8a03ae55dbe6da2d90189b8c6595c6324977cf25 /Lib
parent73eab9f35ca17c7c3b813c717673934b0ab8ed64 (diff)
downloadcpython-0daba822212cd5d6c63384a27f390f0945330c2b.zip
cpython-0daba822212cd5d6c63384a27f390f0945330c2b.tar.gz
cpython-0daba822212cd5d6c63384a27f390f0945330c2b.tar.bz2
gh-94949: Disallow parsing parenthesised ctx mgr with old feature_version (#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>
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_ast.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py
index 5d7e441..480089a 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_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):