summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/basics/try_return.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/basics/try_return.py b/tests/basics/try_return.py
new file mode 100644
index 000000000..492c18d95
--- /dev/null
+++ b/tests/basics/try_return.py
@@ -0,0 +1,11 @@
+# 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))