py: Implement proper re-raising in native codegen's finally handler.

This allows an exception to propagate correctly through a finally
handler.
This commit is contained in:
Damien George
2015-01-21 17:00:01 +00:00
parent 962a5d50c9
commit b6e6b5277f
4 changed files with 15 additions and 5 deletions

View File

@@ -1824,7 +1824,14 @@ STATIC void emit_native_setup_finally(emit_t *emit, mp_uint_t label) {
}
STATIC void emit_native_end_finally(emit_t *emit) {
emit_pre_pop_discard(emit);
// logic:
// exc = pop_stack
// if exc == None: pass
// else: raise exc
// the check if exc is None is done in the MP_F_NATIVE_RAISE stub
vtype_kind_t vtype;
emit_pre_pop_reg(emit, &vtype, REG_ARG_1);
emit_call(emit, MP_F_NATIVE_RAISE);
emit_post(emit);
}