Skip to content

Commit 1752022

Browse files
committed
py: Make all objects and instances derive from object.
This makes isinstance(X, object) and issubclass(X, object) true for all X.
1 parent 7efc5b3 commit 1752022

2 files changed

Lines changed: 2 additions & 3 deletions

File tree

py/objobject.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ typedef struct _mp_obj_object_t {
1111
mp_obj_base_t base;
1212
} mp_obj_object_t;
1313

14-
const mp_obj_type_t mp_type_object;
15-
1614
STATIC mp_obj_t object_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
1715
if (n_args != 0 || n_kw != 0) {
1816
nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError, "object takes no arguments"));

py/objtype.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,8 @@ STATIC mp_obj_t mp_obj_is_subclass(mp_obj_t object, mp_obj_t classinfo) {
532532
}
533533

534534
for (uint i = 0; i < len; i++) {
535-
if (mp_obj_is_subclass_fast(object, items[i])) {
535+
// We explicitly check for 'object' here since no-one explicitly derives from it
536+
if (items[i] == &mp_type_object || mp_obj_is_subclass_fast(object, items[i])) {
536537
return mp_const_true;
537538
}
538539
}

0 commit comments

Comments
 (0)