]> granicus.if.org Git - python/commitdiff
Check return value of _PyDict_SetItemId()
authorChristian Heimes <christian@python.org>
Thu, 13 Oct 2016 19:10:31 +0000 (21:10 +0200)
committerChristian Heimes <christian@python.org>
Thu, 13 Oct 2016 19:10:31 +0000 (21:10 +0200)
Objects/typeobject.c

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