Issue #18408: Fix PyType_Ready(), handle _PyDict_SetItemId() failure

This commit is contained in:
Victor Stinner 2013-07-17 22:01:37 +02:00
parent e901d1fbdf
commit 5967bf4928
1 changed files with 7 additions and 3 deletions

View File

@ -4256,11 +4256,15 @@ PyType_Ready(PyTypeObject *type)
PyObject *doc = PyUnicode_FromString(type->tp_doc);
if (doc == NULL)
goto error;
_PyDict_SetItemId(type->tp_dict, &PyId___doc__, doc);
if (_PyDict_SetItemId(type->tp_dict, &PyId___doc__, doc) < 0) {
Py_DECREF(doc);
goto error;
}
Py_DECREF(doc);
} else {
_PyDict_SetItemId(type->tp_dict,
&PyId___doc__, Py_None);
if (_PyDict_SetItemId(type->tp_dict,
&PyId___doc__, Py_None) < 0)
goto error;
}
}