summaryrefslogtreecommitdiffstats
path: root/Grammar
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2022-11-06 15:36:19 (GMT)
committerGitHub <noreply@github.com>2022-11-06 15:36:19 (GMT)
commit61b6c40b645bd8c8568f1646dc46580fa49d107a (patch)
tree8b7a53cc5aefabbf59ba9cd78c4a07c409e0fd9f /Grammar
parentd3b82b4463c4eb51954c0afd98342f0c5e479baa (diff)
downloadcpython-61b6c40b645bd8c8568f1646dc46580fa49d107a.zip
cpython-61b6c40b645bd8c8568f1646dc46580fa49d107a.tar.gz
cpython-61b6c40b645bd8c8568f1646dc46580fa49d107a.tar.bz2
gh-99153: set location on SyntaxError for try with both except and except* (GH-99160)
Diffstat (limited to 'Grammar')
-rw-r--r--Grammar/python.gram4
1 files changed, 2 insertions, 2 deletions
diff --git a/Grammar/python.gram b/Grammar/python.gram
index 7dfc3df..c947d22 100644
--- a/Grammar/python.gram
+++ b/Grammar/python.gram
@@ -1254,8 +1254,8 @@ invalid_try_stmt:
| a='try' ':' NEWLINE !INDENT {
RAISE_INDENTATION_ERROR("expected an indented block after 'try' statement on line %d", a->lineno) }
| 'try' ':' block !('except' | 'finally') { RAISE_SYNTAX_ERROR("expected 'except' or 'finally' block") }
- | 'try' ':' block* ((except_block+ except_star_block) | (except_star_block+ except_block)) block* {
- RAISE_SYNTAX_ERROR("cannot have both 'except' and 'except*' on the same 'try'") }
+ | a='try' ':' block* ((except_block+ except_star_block) | (except_star_block+ except_block)) block* {
+ RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "cannot have both 'except' and 'except*' on the same 'try'") }
invalid_except_stmt:
| 'except' '*'? a=expression ',' expressions ['as' NAME ] ':' {
RAISE_SYNTAX_ERROR_STARTING_FROM(a, "multiple exception types must be parenthesized") }