diff --git a/Objects/typeobject.c b/Objects/typeobject.c index bd55ede5ffd..f51700e034d 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -691,8 +691,10 @@ type_repr(PyTypeObject *type) 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("", mod, name);