mirror of
https://github.com/python/cpython.git
synced 2025-07-24 19:54:21 +00:00
[3.10] bpo-44305: Improve syntax error for try blocks without except or finally (GH-26523) (GH-26524)
(cherry picked from commit b250f89bb7
)
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
This commit is contained in:
parent
3283bf4519
commit
e53f72a1b4
5 changed files with 554 additions and 440 deletions
|
@ -964,6 +964,7 @@ invalid_with_stmt_indent:
|
|||
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") }
|
||||
invalid_except_stmt:
|
||||
| 'except' a=expression ',' expressions ['as' NAME ] ':' {
|
||||
RAISE_SYNTAX_ERROR_STARTING_FROM(a, "multiple exception types must be parenthesized") }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue