py/vm: Simplify handling of MP_OBJ_STOP_ITERATION in yield-from opcode.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George
2021-06-29 22:39:24 +10:00
parent 22fdb21302
commit b8255dd2e0
3 changed files with 10 additions and 15 deletions

View File

@@ -1272,7 +1272,6 @@ mp_obj_t mp_iternext(mp_obj_t o_in) {
}
}
// TODO: Unclear what to do with StopIterarion exception here.
mp_vm_return_kind_t mp_resume(mp_obj_t self_in, mp_obj_t send_value, mp_obj_t throw_value, mp_obj_t *ret_val) {
assert((send_value != MP_OBJ_NULL) ^ (throw_value != MP_OBJ_NULL));
const mp_obj_type_t *type = mp_obj_get_type(self_in);
@@ -1287,8 +1286,9 @@ mp_vm_return_kind_t mp_resume(mp_obj_t self_in, mp_obj_t send_value, mp_obj_t th
if (ret != MP_OBJ_STOP_ITERATION) {
return MP_VM_RETURN_YIELD;
} else {
// Emulate raise StopIteration()
// Special case, handled in vm.c
// The generator is finished.
// This is an optimised "raise StopIteration(None)".
*ret_val = mp_const_none;
return MP_VM_RETURN_NORMAL;
}
}