runtime: Add TODO for mp_resume() on handling .close().
Exceptions in .close() should be ignored (dumped to sys.stderr, not propagated), but in uPy, they are propagated. Fix would require nlr-wrapping .close() call, which is expensive. Bu on the other hand, .close() is not called often, so maybe that's not too bad (depends, if it's finally called and that causes stack overflow, there's nothing good in that). And yet on another hand, .close() can be implemented to catch exceptions on its side, and that should be the right choice.
This commit is contained in:
parent
717a958256
commit
4a60cac916
|
@ -1113,6 +1113,8 @@ mp_vm_return_kind_t mp_resume(mp_obj_t self_in, mp_obj_t send_value, mp_obj_t th
|
|||
if (mp_obj_is_subclass_fast(mp_obj_get_type(throw_value), &mp_type_GeneratorExit)) {
|
||||
mp_load_method_maybe(self_in, MP_QSTR_close, dest);
|
||||
if (dest[0] != MP_OBJ_NULL) {
|
||||
// TODO: Exceptions raised in close() are not propagated,
|
||||
// printed to sys.stderr
|
||||
*ret_val = mp_call_method_n_kw(0, 0, dest);
|
||||
// We assume one can't "yield" from close()
|
||||
return MP_VM_RETURN_NORMAL;
|
||||
|
|
Loading…
Reference in New Issue