Check return value of _PyDict_SetItemId()

This commit is contained in:
Christian Heimes 2016-10-13 21:10:31 +02:00
parent 2ccdb5a4f1
commit 5cade88ac1
1 changed files with 4 additions and 1 deletions

View File

@ -2848,13 +2848,16 @@ PyType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases)
/* Set type.__module__ */ /* Set type.__module__ */
s = strrchr(spec->name, '.'); s = strrchr(spec->name, '.');
if (s != NULL) { if (s != NULL) {
int err;
modname = PyUnicode_FromStringAndSize( modname = PyUnicode_FromStringAndSize(
spec->name, (Py_ssize_t)(s - spec->name)); spec->name, (Py_ssize_t)(s - spec->name));
if (modname == NULL) { if (modname == NULL) {
goto fail; goto fail;
} }
_PyDict_SetItemId(type->tp_dict, &PyId___module__, modname); err = _PyDict_SetItemId(type->tp_dict, &PyId___module__, modname);
Py_DECREF(modname); Py_DECREF(modname);
if (err != 0)
goto fail;
} else { } else {
if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
"builtin type %.200s has no __module__ attribute", "builtin type %.200s has no __module__ attribute",