Skip to content

Commit bdbd98d

Browse files
committed
fixes start method not being available.
1 parent e01e618 commit bdbd98d

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

ext_mod/threading/esp32/common/src/thread_thread.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,27 @@ void thread_attr_func(mp_obj_t self_in, qstr attr, mp_obj_t *dest)
8585
// load attribute
8686
if (attr == MP_QSTR_name) {
8787
dest[0] = self->name;
88-
}
89-
if (attr == MP_QSTR_ident) {
88+
} else if (attr == MP_QSTR_ident) {
9089
dest[0] = self->ident;
90+
} else {
91+
const mp_obj_type_t *type = mp_obj_get_type(self_in);
92+
93+
while (MP_OBJ_TYPE_HAS_SLOT(type, locals_dict)) {
94+
// generic method lookup
95+
// this is a lookup in the object (ie not class or type)
96+
assert(MP_OBJ_TYPE_GET_SLOT(type, locals_dict)->base.type == &mp_type_dict); // MicroPython restriction, for now
97+
mp_map_t *locals_map = &MP_OBJ_TYPE_GET_SLOT(type, locals_dict)->map;
98+
mp_map_elem_t *elem = mp_map_lookup(locals_map, MP_OBJ_NEW_QSTR(attr), MP_MAP_LOOKUP);
99+
if (elem != NULL) {
100+
mp_convert_member_lookup(self_in, type, elem->value, dest);
101+
break;
102+
}
103+
if (MP_OBJ_TYPE_GET_SLOT_OR_NULL(type, parent) == NULL) {
104+
break;
105+
}
106+
// search parents
107+
type = MP_OBJ_TYPE_GET_SLOT(type, parent);
108+
}
91109
}
92110
}
93111
}

0 commit comments

Comments
 (0)