diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 818a00708b5d3d..1fa1220aeec648 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -9564,6 +9564,7 @@ add_tp_new_wrapper(PyTypeObject *type) if (func == NULL) { return -1; } + _PyObject_SetDeferredRefcount(func); r = PyDict_SetItem(dict, &_Py_ID(__new__), func); Py_DECREF(func); return r;