summaryrefslogtreecommitdiff
path: root/py/objfun.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-02-15 22:55:00 +0000
committerDamien George <damien.p.george@gmail.com>2014-02-15 22:55:00 +0000
commitc8f78bc280447a06802d6456e8e759872e82246d (patch)
tree2faf58e60132f9f936e0274226987bda33ee5c91 /py/objfun.c
parent36109d246fc5396c38bedfc240ddbe60a3c718fc (diff)
py: VM never throws an exception, instead returns a status and value.
Addresses issue #290, and hopefully sets up things to allow generators throwing exceptions, etc.
Diffstat (limited to 'py/objfun.c')
-rw-r--r--py/objfun.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/py/objfun.c b/py/objfun.c
index 433da039b..0c7ccf798 100644
--- a/py/objfun.c
+++ b/py/objfun.c
@@ -152,10 +152,15 @@ STATIC mp_obj_t fun_bc_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_o
uint use_def_args = self->n_args - n_args;
mp_map_t *old_globals = rt_globals_get();
rt_globals_set(self->globals);
- mp_obj_t result = mp_execute_byte_code(self->bytecode, args, n_args, self->def_args + self->n_def_args - use_def_args, use_def_args, self->n_state);
+ mp_obj_t result;
+ mp_vm_return_kind_t vm_return_kind = mp_execute_byte_code(self->bytecode, args, n_args, self->def_args + self->n_def_args - use_def_args, use_def_args, self->n_state, &result);
rt_globals_set(old_globals);
- return result;
+ if (vm_return_kind == MP_VM_RETURN_NORMAL) {
+ return result;
+ } else { // MP_VM_RETURN_EXCEPTION
+ nlr_jump(result);
+ }
}
const mp_obj_type_t fun_bc_type = {