From b9bad7ff927448fc0b4c881bf37fea632958fb7a Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Fri, 28 Sep 2018 21:49:42 +0300 Subject: [PATCH] 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. --- ports/unix/moduselect.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ports/unix/moduselect.c b/ports/unix/moduselect.c index 4fa8d3ae80..a95663e31f 100644 --- a/ports/unix/moduselect.c +++ b/ports/unix/moduselect.c @@ -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--) { if (entries->fd == fd) { entries->events = mp_obj_get_int(eventmask_in); - break; + return mp_const_none; } entries++; } - // TODO raise KeyError if obj didn't exist in map - return mp_const_none; + // obj doesn't exist in poller + mp_raise_OSError(MP_ENOENT); } MP_DEFINE_CONST_FUN_OBJ_3(poll_modify_obj, poll_modify);