aboutsummaryrefslogtreecommitdiff
path: root/py/runtime.c
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2021-06-29 22:39:24 +1000
committerDamien George <damien@micropython.org>2021-07-15 00:12:41 +1000
commitb8255dd2e00f926106083de7a9b41869b226e96b (patch)
tree8da297bf82457a2527e303b45362415bcd7eb5b1 /py/runtime.c
parent22fdb2130284ddea3ebe1d271d05d670546e788f (diff)
py/vm: Simplify handling of MP_OBJ_STOP_ITERATION in yield-from opcode.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'py/runtime.c')
-rw-r--r--py/runtime.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/py/runtime.c b/py/runtime.c
index 261670d4f..b53711bbe 100644
--- a/py/runtime.c
+++ b/py/runtime.c
@@ -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;
}
}