diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index a720a98121dc93..0924df4def45b6 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -1652,6 +1652,9 @@ mro_hierarchy(PyTypeObject *type, PyObject *temp)
         return res;
     }
     PyObject *new_mro = lookup_tp_mro(type);
+    if (new_mro == NULL) {
+        return -1;
+    }
 
     PyObject *tuple;
     if (old_mro != NULL) {