Skip to content

Commit 2b67a40

Browse files
committed
objtype: Clarify comment for mp_obj_class_lookup().
1 parent 66c11ec commit 2b67a40

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

py/objtype.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,15 @@ STATIC int instance_count_native_bases(const mp_obj_type_t *type, const mp_obj_t
9090
// http://python-history.blogspot.com/2010/06/method-resolution-order.html
9191
// https://www.python.org/download/releases/2.3/mro/
9292
//
93-
// will return MP_OBJ_NULL if not found
94-
// will return MP_OBJ_SENTINEL if special method was found in a native type base
95-
// via slot id (meth_offset). As there can be only one native base, it's known that it
96-
// applies to instance->subobj[0]. In most cases, we also don't need to know which type
97-
// it was - because instance->subobj[0] is of that type. The only exception is when
98-
// object is not yet constructed, then we need to know base native type to construct
99-
// instance->subobj[0]. This case is handled via instance_count_native_bases() though.
93+
// will keep lookup->dest[0]'s value (should be MP_OBJ_NULL on invocation) if attribute
94+
// is not found
95+
// will set lookup->dest[0] to MP_OBJ_SENTINEL if special method was found in a native
96+
// type base via slot id (as specified by lookup->meth_offset). As there can be only one
97+
// native base, it's known that it applies to instance->subobj[0]. In most cases, we also
98+
// don't need to know which type it was - because instance->subobj[0] is of that type.
99+
// The only exception is when object is not yet constructed, then we need to know base
100+
// native type to construct its instance->subobj[0] from. But this case is handled via
101+
// instance_count_native_bases(), which returns a native base which it saw.
100102
struct class_lookup_data {
101103
mp_obj_instance_t *obj;
102104
qstr attr;

0 commit comments

Comments
 (0)