unix/moduselect: Raise OSError(ENOENT) if obj to modify is not in poller

Previously, the function silently succeeded. The new behavior is consistent
with both baremetal uselect implementation and CPython 3.
This commit is contained in:
Paul Sokolovsky 2018-09-28 21:49:42 +03:00 committed by Damien George
parent cb66b75692
commit b9bad7ff92

View File

@ -158,13 +158,13 @@ STATIC mp_obj_t poll_modify(mp_obj_t self_in, mp_obj_t obj_in, mp_obj_t eventmas
for (int i = self->len - 1; i >= 0; i--) { for (int i = self->len - 1; i >= 0; i--) {
if (entries->fd == fd) { if (entries->fd == fd) {
entries->events = mp_obj_get_int(eventmask_in); entries->events = mp_obj_get_int(eventmask_in);
break; return mp_const_none;
} }
entries++; entries++;
} }
// TODO raise KeyError if obj didn't exist in map // obj doesn't exist in poller
return mp_const_none; mp_raise_OSError(MP_ENOENT);
} }
MP_DEFINE_CONST_FUN_OBJ_3(poll_modify_obj, poll_modify); MP_DEFINE_CONST_FUN_OBJ_3(poll_modify_obj, poll_modify);