summaryrefslogtreecommitdiff
path: root/py/emitnative.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2018-09-03 17:41:02 +1000
committerDamien George <damien.p.george@gmail.com>2018-09-03 17:41:02 +1000
commit3cd2c281d7cf990b3afb78287a58cf4ee3f23ca5 (patch)
treeaf1ec7ff9ae66946cf02c96f37c989979291ce18 /py/emitnative.c
parentb735208403a54774f9fd3d966f7c1a194c41870f (diff)
py/emitnative: Cancel caught exception once handled to prevent reraise.
The native emitter keeps the current exception in a slot in its C stack (instead of on its Python value stack), so when it catches an exception it must explicitly clear that slot so the same exception is not reraised later on.
Diffstat (limited to 'py/emitnative.c')
-rw-r--r--py/emitnative.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/py/emitnative.c b/py/emitnative.c
index 5db496a22..a5075eead 100644
--- a/py/emitnative.c
+++ b/py/emitnative.c
@@ -1892,7 +1892,9 @@ STATIC void emit_native_pop_block(emit_t *emit) {
}
STATIC void emit_native_pop_except(emit_t *emit) {
- (void)emit;
+ // Cancel any active exception so subsequent handlers don't see it
+ ASM_MOV_REG_IMM(emit->as, REG_TEMP0, (mp_uint_t)mp_const_none);
+ ASM_MOV_LOCAL_REG(emit->as, LOCAL_IDX_EXC_VAL(emit), REG_TEMP0);
}
STATIC void emit_native_unary_op(emit_t *emit, mp_unary_op_t op) {