Skip to content

Commit c82b85a

Browse files
committed
Revert "pythongh-94949: Disallow parsing parenthesised ctx mgr with old feature_version (python#94950)"
This reverts commit 0daba82.
1 parent a8b1c82 commit c82b85a

File tree

3 files changed

+2
-10
lines changed

3 files changed

+2
-10
lines changed

Grammar/python.gram

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ for_stmt[stmt_ty]:
393393
with_stmt[stmt_ty]:
394394
| invalid_with_stmt_indent
395395
| 'with' '(' a[asdl_withitem_seq*]=','.with_item+ ','? ')' ':' tc=[TYPE_COMMENT] b=block {
396-
CHECK_VERSION(stmt_ty, 9, "Parenthesized context managers are", _PyAST_With(a, b, NEW_TYPE_COMMENT(p, tc), EXTRA)) }
396+
_PyAST_With(a, b, NEW_TYPE_COMMENT(p, tc), EXTRA) }
397397
| 'with' a[asdl_withitem_seq*]=','.with_item+ ':' tc=[TYPE_COMMENT] b=block {
398398
_PyAST_With(a, b, NEW_TYPE_COMMENT(p, tc), EXTRA) }
399399
| 'async' 'with' '(' a[asdl_withitem_seq*]=','.with_item+ ','? ')' ':' b=block {

Lib/test/test_ast.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,14 +1045,6 @@ def test_positional_only_feature_version(self):
10451045
with self.assertRaises(SyntaxError):
10461046
ast.parse('lambda x=1, /: ...', feature_version=(3, 7))
10471047

1048-
def test_parenthesized_with_feature_version(self):
1049-
ast.parse('with (CtxManager() as example): ...', feature_version=(3, 10))
1050-
# While advertised as a feature in Python 3.10, this was allowed starting 3.9
1051-
ast.parse('with (CtxManager() as example): ...', feature_version=(3, 9))
1052-
with self.assertRaises(SyntaxError):
1053-
ast.parse('with (CtxManager() as example): ...', feature_version=(3, 8))
1054-
ast.parse('with CtxManager() as example: ...', feature_version=(3, 8))
1055-
10561048
def test_assignment_expression_feature_version(self):
10571049
ast.parse('(x := 0)', feature_version=(3, 8))
10581050
with self.assertRaises(SyntaxError):

Parser/parser.c

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)