aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Sokolovsky2015-05-10 02:39:45 +0300
committerPaul Sokolovsky2015-05-10 02:39:45 +0300
commit4a60cac9162f8f2aa25a2de4025493d38113ae54 (patch)
tree9a5c6d2caa79cfd64c94f97e9ecb0417b3915a0b
parent717a9582560a333a60191eb83c61ef179419949f (diff)
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.
-rw-r--r--py/runtime.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/py/runtime.c b/py/runtime.c
index 68728642b..a6cf7e017 100644
--- a/py/runtime.c
+++ b/py/runtime.c
@@ -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;