summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--py/emitnative.c2
-rw-r--r--tests/basics/try_finally1.py12
2 files changed, 13 insertions, 1 deletions
diff --git a/py/emitnative.c b/py/emitnative.c
index 6a5bcd7ee..73899b9e9 100644
--- a/py/emitnative.c
+++ b/py/emitnative.c
@@ -914,7 +914,7 @@ STATIC void emit_native_label_assign(emit_t *emit, mp_uint_t l) {
if (is_finally) {
// Label is at start of finally handler: pop exception stack
- emit_native_leave_exc_stack(emit, true);
+ emit_native_leave_exc_stack(emit, false);
}
}
diff --git a/tests/basics/try_finally1.py b/tests/basics/try_finally1.py
index 1e821deb6..67ebe0b59 100644
--- a/tests/basics/try_finally1.py
+++ b/tests/basics/try_finally1.py
@@ -82,3 +82,15 @@ finally:
print("except2")
print("finally1")
print()
+
+# case where exception is raised after a finally has finished (tests that the finally doesn't run again)
+def func():
+ try:
+ print("try")
+ finally:
+ print("finally")
+ foo
+try:
+ func()
+except:
+ print("except")