mp_resume: Dare to pass send_value of NULL.
There was thinkos that either send_value or throw_value is specified, but there were cases with both. Note that send_value is pushed onto generator's stack - but that's probably only good, because if we throw exception into gen, it should not ever use send_value, and that will be just extra "assert".
This commit is contained in:
parent
a2109d9321
commit
7da0660516
@ -915,6 +915,7 @@ mp_obj_t mp_iternext(mp_obj_t o_in) {
|
|||||||
|
|
||||||
// TODO: Unclear what to do with StopIterarion exception here.
|
// 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) {
|
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));
|
||||||
mp_obj_type_t *type = mp_obj_get_type(self_in);
|
mp_obj_type_t *type = mp_obj_get_type(self_in);
|
||||||
|
|
||||||
if (type == &mp_type_gen_instance) {
|
if (type == &mp_type_gen_instance) {
|
||||||
|
2
py/vm.c
2
py/vm.c
@ -764,7 +764,7 @@ yield:
|
|||||||
if (inject_exc != MP_OBJ_NULL) {
|
if (inject_exc != MP_OBJ_NULL) {
|
||||||
t_exc = inject_exc;
|
t_exc = inject_exc;
|
||||||
inject_exc = MP_OBJ_NULL;
|
inject_exc = MP_OBJ_NULL;
|
||||||
ret_kind = mp_resume(TOP(), mp_const_none, t_exc, &obj2);
|
ret_kind = mp_resume(TOP(), MP_OBJ_NULL, t_exc, &obj2);
|
||||||
} else {
|
} else {
|
||||||
ret_kind = mp_resume(TOP(), obj1, MP_OBJ_NULL, &obj2);
|
ret_kind = mp_resume(TOP(), obj1, MP_OBJ_NULL, &obj2);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user