diff options
author | Pablo Galindo <Pablogsal@gmail.com> | 2021-06-03 23:11:43 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-03 23:11:43 (GMT) |
commit | e53f72a1b42e17a331ed14bec674b1ee01d0720c (patch) | |
tree | fd4f350d1f95abc3f8107ebf9167a554d93ba23d /Grammar | |
parent | 3283bf4519139cf62ba04a76930f84ca1e7da910 (diff) | |
download | cpython-e53f72a1b42e17a331ed14bec674b1ee01d0720c.zip cpython-e53f72a1b42e17a331ed14bec674b1ee01d0720c.tar.gz cpython-e53f72a1b42e17a331ed14bec674b1ee01d0720c.tar.bz2 |
[3.10] bpo-44305: Improve syntax error for try blocks without except or finally (GH-26523) (GH-26524)
(cherry picked from commit b250f89bb7e05e72a4641d44b988866b919575db)
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
Diffstat (limited to 'Grammar')
-rw-r--r-- | Grammar/python.gram | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/Grammar/python.gram b/Grammar/python.gram index 8b5d921..d0f9bb0 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -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") } |