Skip to content

Commit 3cb7663

Browse files
committed
objtype: Refactor dealing with native sub-objects for clarity.
1 parent f0dc0d5 commit 3cb7663

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

py/objtype.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,13 @@ STATIC void mp_obj_class_lookup(struct class_lookup_data *lookup, const mp_obj_
135135
// not type where we found a class method.
136136
const mp_obj_type_t *org_type = (const mp_obj_type_t*)lookup->obj;
137137
instance_convert_return_attr(NULL, org_type, elem->value, lookup->dest);
138-
} else if (lookup->obj != MP_OBJ_NULL && is_native_type(type) && type != &mp_type_object /* object is not a real type */) {
139-
instance_convert_return_attr(lookup->obj->subobj[0], type, elem->value, lookup->dest);
140138
} else {
141-
instance_convert_return_attr(lookup->obj, type, elem->value, lookup->dest);
139+
mp_obj_instance_t *obj = lookup->obj;
140+
if (obj != MP_OBJ_NULL && is_native_type(type) && type != &mp_type_object /* object is not a real type */) {
141+
// If we're dealing with native base class, then it applies to native sub-object
142+
obj = obj->subobj[0];
143+
}
144+
instance_convert_return_attr(obj, type, elem->value, lookup->dest);
142145
}
143146
#if DEBUG_PRINT
144147
printf("mp_obj_class_lookup: Returning: ");

0 commit comments

Comments
 (0)