Skip to content

Commit 160b692

Browse files
committed
Fix ambiguity in try/except statement grammar
1 parent 52f190f commit 160b692

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

parser/grammar.y

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,10 @@ if_stmt: IF test ':' suite elifs optional_else
216216
while_stmt: WHILE test ':' suite optional_else
217217
for_stmt: FOR exprlist IN testlist ':' suite optional_else
218218
except_clauses: | except_clauses except_clause ':' suite
219-
try_stmt: TRY ':' suite except_clauses optional_else
220-
| TRY ':' suite except_clauses optional_else FINALLY ':' suite
221-
| TRY ':' suite FINALLY ':' suite
219+
try_stmt: TRY ':' suite except_clauses
220+
| TRY ':' suite except_clauses ELSE ':' suite
221+
| TRY ':' suite except_clauses FINALLY ':' suite
222+
| TRY ':' suite except_clauses ELSE ':' suite FINALLY ':' suite
222223
with_items: with_item | with_items ',' with_item
223224
with_stmt: WITH with_items ':' suite
224225
with_item: test | test AS expr

0 commit comments

Comments
 (0)