[Python-checkins] cpython (3.6): Check return value of _PyDict_SetItemId()

christian.heimes python-checkins at python.org
Thu Oct 13 15:10:56 EDT 2016


https://hg.python.org/cpython/rev/fa6767289ce6
changeset:   104472:fa6767289ce6
branch:      3.6
parent:      104470:64a38f9aee21
user:        Christian Heimes <christian at python.org>
date:        Thu Oct 13 21:10:31 2016 +0200
summary:
  Check return value of _PyDict_SetItemId()

files:
  Objects/typeobject.c |  5 ++++-
  1 files changed, 4 insertions(+), 1 deletions(-)


diff --git a/Objects/typeobject.c b/Objects/typeobject.c
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -2848,13 +2848,16 @@
     /* 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",

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list