summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Heimes <christian@python.org>2016-10-13 19:10:42 (GMT)
committerChristian Heimes <christian@python.org>2016-10-13 19:10:42 (GMT)
commite590a03db752882288046c747df983f44aac32c7 (patch)
tree2581dafc15ded1a8a35c83fda9ce60f9bdcafe60
parentcf418eabc0acb85bf370238a6d4faf0e2125d586 (diff)
parent5cade88ac1cf9241a8052c68646beac08aaa718e (diff)
downloadcpython-e590a03db752882288046c747df983f44aac32c7.zip
cpython-e590a03db752882288046c747df983f44aac32c7.tar.gz
cpython-e590a03db752882288046c747df983f44aac32c7.tar.bz2
Check return value of _PyDict_SetItemId()
-rw-r--r--Objects/typeobject.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 1960c1a..1021a75 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -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",