diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 5e772e5608d4c66..87da481f0a5f60c 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -7472,7 +7472,9 @@ _Py_BaseObject_RichCompare(PyObject* self, PyObject* other, int op) static PyObject * object_get_class(PyObject *self, void *closure) { - return Py_NewRef(Py_TYPE(self)); + PyTypeObject *type = Py_TYPE(self); + _Py_INCREF_TYPE(type); + return (PyObject *)type; } static int