mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
gh-99211: Point to except/except* on syntax errors when mixing them (GH-99215)
Automerge-Triggered-By: GH:lysnikolaou
This commit is contained in:
parent
b0e1f9c241
commit
9c4232ae89
3 changed files with 1018 additions and 974 deletions
|
@ -1254,7 +1254,9 @@ 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") }
|
||||
| a='try' ':' block* ((except_block+ except_star_block) | (except_star_block+ except_block)) block* {
|
||||
| 'try' ':' block* except_block+ a='except' b='*' expression ['as' NAME] ':' {
|
||||
RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "cannot have both 'except' and 'except*' on the same 'try'") }
|
||||
| 'try' ':' block* except_star_block+ a='except' [expression ['as' NAME]] ':' {
|
||||
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 ] ':' {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue