Skip to content

Commit ebc8d73

Browse files
committed
extmod/moduselect: Use stream helper function instead of ad-hoc code.
1 parent 304cfda commit ebc8d73

1 file changed

Lines changed: 1 addition & 5 deletions

File tree

extmod/moduselect.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,7 @@ STATIC void poll_map_add(mp_map_t *poll_map, const mp_obj_t *obj, mp_uint_t obj_
5555
mp_map_elem_t *elem = mp_map_lookup(poll_map, mp_obj_id(obj[i]), MP_MAP_LOOKUP_ADD_IF_NOT_FOUND);
5656
if (elem->value == NULL) {
5757
// object not found; get its ioctl and add it to the poll list
58-
mp_obj_type_t *type = mp_obj_get_type(obj[i]);
59-
const mp_stream_p_t *stream_p = type->protocol;
60-
if (stream_p == NULL || stream_p->ioctl == NULL) {
61-
nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError, "object with stream.ioctl required"));
62-
}
58+
const mp_stream_p_t *stream_p = mp_get_stream_raise(obj[i], MP_STREAM_OP_IOCTL);
6359
poll_obj_t *poll_obj = m_new_obj(poll_obj_t);
6460
poll_obj->obj = obj[i];
6561
poll_obj->ioctl = stream_p->ioctl;

0 commit comments

Comments
 (0)