gh-133194: Add CHECK_VERSION to new PEP758 grammar (#133195)

This commit is contained in:
sobolevn
2025-04-30 13:39:26 +03:00
committed by GitHub
parent 44e4c479fb
commit b1f893875b
4 changed files with 36 additions and 4 deletions

View File

@@ -442,7 +442,11 @@ try_stmt[stmt_ty]:
except_block[excepthandler_ty]:
| invalid_except_stmt_indent
| 'except' e=expressions ':' b=block {
_PyAST_ExceptHandler(e, NULL, b, EXTRA) }
CHECK_VERSION(
excepthandler_ty,
14,
"except expressions without parentheses",
_PyAST_ExceptHandler(e, NULL, b, EXTRA)) }
| 'except' e=expression 'as' t=NAME ':' b=block {
_PyAST_ExceptHandler(e, ((expr_ty) t)->v.Name.id, b, EXTRA) }
| 'except' ':' b=block { _PyAST_ExceptHandler(NULL, NULL, b, EXTRA) }
@@ -450,7 +454,11 @@ except_block[excepthandler_ty]:
except_star_block[excepthandler_ty]:
| invalid_except_star_stmt_indent
| 'except' '*' e=expressions ':' b=block {
_PyAST_ExceptHandler(e, NULL, b, EXTRA) }
CHECK_VERSION(
excepthandler_ty,
14,
"except expressions without parentheses",
_PyAST_ExceptHandler(e, NULL, b, EXTRA)) }
| 'except' '*' e=expression 'as' t=NAME ':' b=block {
_PyAST_ExceptHandler(e, ((expr_ty) t)->v.Name.id, b, EXTRA) }
| invalid_except_star_stmt