diff options
author | Damien George <damien.p.george@gmail.com> | 2015-12-24 12:47:39 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-12-24 12:47:39 +0000 |
commit | 8047340d7532ec32bc9f2d603bffc0bc9544297f (patch) | |
tree | 2a1eced095349199a049e82f0c9a080de13fb9b3 /py/vm.c | |
parent | 117158fcd560a84318a0b9cb5332c5599acdb84b (diff) |
py: Handle case of return within the finally block of try-finally.
Addresses issue #1636.
Diffstat (limited to 'py/vm.c')
-rw-r--r-- | py/vm.c | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -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)) { |