Skip to content

Commit 430efb0

Browse files
committed
tests/basics: Add test for use of return within try-except.
The case of a return statement in the try suite of a try-except statement was previously only tested by builtin_compile.py, and only then in the part of this test which checked for the existence of the compile builtin. So this patch adds an explicit unit test for this case.
1 parent bc36521 commit 430efb0

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

tests/basics/try_return.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# test use of return with try-except
2+
3+
def f(l, i):
4+
try:
5+
return l[i]
6+
except IndexError:
7+
print('IndexError')
8+
return -1
9+
10+
print(f([1], 0))
11+
print(f([], 0))

0 commit comments

Comments
 (0)