summaryrefslogtreecommitdiffstatshomepage
path: root/py/vm.c
diff options
context:
space:
mode:
Diffstat (limited to 'py/vm.c')
-rw-r--r--py/vm.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/py/vm.c b/py/vm.c
index 8bf59f1e05..8c7c2265e4 100644
--- a/py/vm.c
+++ b/py/vm.c
@@ -1032,6 +1032,14 @@ unwind_jump:;
ENTRY(MP_BC_RETURN_VALUE):
MARK_EXC_IP_SELECTIVE();
+ // These next 3 lines pop a try-finally exception handler, if one
+ // is there on the exception stack. Without this the finally block
+ // is executed a second time when the return is executed, because
+ // the try-finally exception handler is still on the stack.
+ // TODO Possibly find a better way to handle this case.
+ if (currently_in_except_block) {
+ POP_EXC_BLOCK();
+ }
unwind_return:
while (exc_sp >= exc_stack) {
if (MP_TAGPTR_TAG1(exc_sp->val_sp)) {