From b6e6b5277f4fb966d8090e362f187d36117b2db6 Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 21 Jan 2015 17:00:01 +0000 Subject: py: Implement proper re-raising in native codegen's finally handler. This allows an exception to propagate correctly through a finally handler. --- py/nativeglue.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'py/nativeglue.c') diff --git a/py/nativeglue.c b/py/nativeglue.c index d52eeaeaa..43e7d699f 100644 --- a/py/nativeglue.c +++ b/py/nativeglue.c @@ -80,8 +80,11 @@ mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, mp_uint_t n_args_kw, cons } // wrapper that makes raise obj and raises it -NORETURN void mp_native_raise(mp_obj_t o) { - nlr_raise(mp_make_raise_obj(o)); +// END_FINALLY opcode requires that we don't raise if o==None +void mp_native_raise(mp_obj_t o) { + if (o != mp_const_none) { + nlr_raise(mp_make_raise_obj(o)); + } } // these must correspond to the respective enum in runtime0.h -- cgit v1.2.3