Skip to content

Commit 6ce78c4

Browse files
committed
py: Wrap .__class__ handling in MICROPY_CPYTHON_COMPAT.
Because it's superfluos in the presence of type(), a remenant from Python's "old classes".
1 parent b509f73 commit 6ce78c4

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

py/runtime.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,10 +716,13 @@ STATIC void mp_load_method_maybe(mp_obj_t base, qstr attr, mp_obj_t *dest) {
716716

717717
// if nothing found yet, look for built-in and generic names
718718
if (dest[0] == MP_OBJ_NULL) {
719+
#if MICROPY_CPYTHON_COMPAT
719720
if (attr == MP_QSTR___class__) {
720721
// a.__class__ is equivalent to type(a)
721722
dest[0] = type;
722-
} else if (attr == MP_QSTR___next__ && type->iternext != NULL) {
723+
} else
724+
#endif
725+
if (attr == MP_QSTR___next__ && type->iternext != NULL) {
723726
dest[0] = (mp_obj_t)&mp_builtin_next_obj;
724727
dest[1] = base;
725728
} else if (type->load_attr == NULL) {

0 commit comments

Comments
 (0)