From 17520224fad7a0c4a742f9b8a46e016c2ba3cc46 Mon Sep 17 00:00:00 2001
From: Damien George <damien.p.george@gmail.com>
Date: Sat, 5 Apr 2014 22:45:23 +0100
Subject: [PATCH] py: Make all objects and instances derive from object.

This makes isinstance(X, object) and issubclass(X, object) true for all
X.
---
 py/objobject.c | 2 --
 py/objtype.c   | 3 ++-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/py/objobject.c b/py/objobject.c
index 56daa956d..74a4926b3 100644
--- a/py/objobject.c
+++ b/py/objobject.c
@@ -11,8 +11,6 @@ typedef struct _mp_obj_object_t {
     mp_obj_base_t base;
 } mp_obj_object_t;
 
-const mp_obj_type_t mp_type_object;
-
 STATIC mp_obj_t object_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
     if (n_args != 0 || n_kw != 0) {
         nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError, "object takes no arguments"));
diff --git a/py/objtype.c b/py/objtype.c
index e8201ca07..92f1f5703 100644
--- a/py/objtype.c
+++ b/py/objtype.c
@@ -532,7 +532,8 @@ STATIC mp_obj_t mp_obj_is_subclass(mp_obj_t object, mp_obj_t classinfo) {
     }
 
     for (uint i = 0; i < len; i++) {
-        if (mp_obj_is_subclass_fast(object, items[i])) {
+        // We explicitly check for 'object' here since no-one explicitly derives from it
+        if (items[i] == &mp_type_object || mp_obj_is_subclass_fast(object, items[i])) {
             return mp_const_true;
         }
     }
-- 
GitLab