mirror of
https://github.com/micropython/micropython.git
synced 2025-09-05 17:30:41 +02:00
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.
12 lines
183 B
Python
12 lines
183 B
Python
# test use of return with try-except
|
|
|
|
def f(l, i):
|
|
try:
|
|
return l[i]
|
|
except IndexError:
|
|
print('IndexError')
|
|
return -1
|
|
|
|
print(f([1], 0))
|
|
print(f([], 0))
|