From f2788585dc143095c6613124cc173574d86b5edd Mon Sep 17 00:00:00 2001 From: Kumar Aditya Date: Fri, 23 Oct 2026 12:40:17 +0530 Subject: [PATCH] use _Py_INCREF_TYPE in object.__class__ --- Objects/typeobject.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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