summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--py/objfun.c2
-rw-r--r--py/objgenerator.c3
-rw-r--r--py/vm.c2
3 files changed, 3 insertions, 4 deletions
diff --git a/py/objfun.c b/py/objfun.c
index b03d4194fc..ce6fd22a5b 100644
--- a/py/objfun.c
+++ b/py/objfun.c
@@ -318,7 +318,7 @@ STATIC mp_obj_t fun_bc_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const
// must be an exception because normal functions can't yield
assert(vm_return_kind == MP_VM_RETURN_EXCEPTION);
// return value is in fastn[0]==state[n_state - 1]
- result = code_state->state[n_state - 1];
+ result = code_state->state[0];
}
#if MICROPY_ENABLE_PYSTACK
diff --git a/py/objgenerator.c b/py/objgenerator.c
index 038c15fc3d..58a33d40b4 100644
--- a/py/objgenerator.c
+++ b/py/objgenerator.c
@@ -140,9 +140,8 @@ mp_vm_return_kind_t mp_obj_gen_resume(mp_obj_t self_in, mp_obj_t send_value, mp_
break;
case MP_VM_RETURN_EXCEPTION: {
- size_t n_state = mp_decode_uint_value(self->code_state.fun_bc->bytecode);
self->code_state.ip = 0;
- *ret_val = self->code_state.state[n_state - 1];
+ *ret_val = self->code_state.state[0];
// PEP479: if StopIteration is raised inside a generator it is replaced with RuntimeError
if (mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(mp_obj_get_type(*ret_val)), MP_OBJ_FROM_PTR(&mp_type_StopIteration))) {
*ret_val = mp_obj_new_exception_msg(&mp_type_RuntimeError, "generator raised StopIteration");
diff --git a/py/vm.c b/py/vm.c
index 8da40c9b68..828ea79e50 100644
--- a/py/vm.c
+++ b/py/vm.c
@@ -1468,7 +1468,7 @@ unwind_loop:
} else {
// propagate exception to higher level
// Note: ip and sp don't have usable values at this point
- fastn[0] = MP_OBJ_FROM_PTR(nlr.ret_val); // must put exception here because sp is invalid
+ code_state->state[0] = MP_OBJ_FROM_PTR(nlr.ret_val); // put exception here because sp is invalid
return MP_VM_RETURN_EXCEPTION;
}
}