diff --git a/Objects/typeobject.c b/Objects/typeobject.c index f51700e034d..88cca93dd10 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -3130,8 +3130,10 @@ object_repr(PyObject *self) mod = NULL; } name = type_qualname(type, NULL); - if (name == NULL) + if (name == NULL) { + Py_XDECREF(mod); return NULL; + } if (mod != NULL && PyUnicode_CompareWithASCIIString(mod, "builtins")) rtn = PyUnicode_FromFormat("<%U.%U object at %p>", mod, name, self); else