Commits

Benjamin Peterson committed 07b0437 Merge

merge 3.2 (#14752)

Comments (0)

Files changed (1)

Objects/typeobject.c

 
     for (; meth->ml_name != NULL; meth++) {
         PyObject *descr;
+        int err;
         if (PyDict_GetItemString(dict, meth->ml_name) &&
             !(meth->ml_flags & METH_COEXIST))
                 continue;
         }
         if (descr == NULL)
             return -1;
-        if (PyDict_SetItemString(dict, meth->ml_name, descr) < 0)
+        err = PyDict_SetItemString(dict, meth->ml_name, descr);
+        Py_DECREF(descr);
+        if (err < 0)
             return -1;
-        Py_DECREF(descr);
     }
     return 0;
 }