diff --git a/py/vm.c b/py/vm.c index 71e804c47f..141315ea8e 100644 --- a/py/vm.c +++ b/py/vm.c @@ -674,7 +674,7 @@ unwind_jump:; exc_sp--; // pop exception handler goto dispatch_loop; // run the exception handler } - exc_sp--; + POP_EXC_BLOCK(); } ip = (const byte*)MP_OBJ_TO_PTR(POP()); // pop destination ip for jump if (unum != 0) { diff --git a/tests/basics/try_continue.py b/tests/basics/try_continue.py new file mode 100644 index 0000000000..4a199b8a38 --- /dev/null +++ b/tests/basics/try_continue.py @@ -0,0 +1,13 @@ +# test continue within exception handler + +def f(): + lst = [1, 2, 3] + for x in lst: + print('a', x) + try: + if x == 2: + raise Exception + except Exception: + continue + print('b', x) +f()