From 430efb044400ae191edc0d1a1654b875284313a7 Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 4 Apr 2018 01:43:16 +1000 Subject: [PATCH] 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. --- tests/basics/try_return.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 tests/basics/try_return.py diff --git a/tests/basics/try_return.py b/tests/basics/try_return.py new file mode 100644 index 0000000000..492c18d95c --- /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))