diff options
author | Damien George <damien.p.george@gmail.com> | 2015-01-21 17:00:01 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-01-21 17:00:01 +0000 |
commit | b6e6b5277f4fb966d8090e362f187d36117b2db6 (patch) | |
tree | e69854cabd65616698610aa381d5fa5660a34fd2 /py/emitnative.c | |
parent | 962a5d50c94f01ca8dc7d46fe568535d713d59d0 (diff) | |
download | micropython-b6e6b5277f4fb966d8090e362f187d36117b2db6.tar.gz micropython-b6e6b5277f4fb966d8090e362f187d36117b2db6.zip |
py: Implement proper re-raising in native codegen's finally handler.
This allows an exception to propagate correctly through a finally
handler.
Diffstat (limited to 'py/emitnative.c')
-rw-r--r-- | py/emitnative.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/py/emitnative.c b/py/emitnative.c index 0721636185..ad89fb845f 100644 --- a/py/emitnative.c +++ b/py/emitnative.c @@ -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); } |