Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit af82141

Browse files
committed
Tighten syntax for try statements
1 parent 14f43cf commit af82141

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

Grammar/Grammar

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | funcdef | classdef
9292
if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite]
9393
while_stmt: 'while' test ':' suite ['else' ':' suite]
9494
for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite]
95-
try_stmt: 'try' ':' suite (except_clause ':' suite)* ['finally' ':' suite]
95+
try_stmt: 'try' ':' suite (except_clause ':' suite)+ | 'try' ':' suite 'finally' ':' suite
96+
# NB compile.c makes sure that the default except clause is last
9697
except_clause: 'except' [test [',' test]]
9798
suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT
9899

0 commit comments

Comments
 (0)