From: Victor Stinner Date: Wed, 17 Jul 2013 19:54:25 +0000 (+0200) Subject: Issue #18408: Fix PyErr_SetImportError(), handle PyDict_SetItemString() failure X-Git-Tag: v3.4.0a1~165 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=479054bca7722daa2e6b62da474fd49c8fafbbee;p=python Issue #18408: Fix PyErr_SetImportError(), handle PyDict_SetItemString() failure --- diff --git a/Python/errors.c b/Python/errors.c index 53dd9a9650..c693b78cac 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -655,8 +655,11 @@ PyErr_SetImportError(PyObject *msg, PyObject *name, PyObject *path) Py_INCREF(msg); PyTuple_SET_ITEM(args, 0, msg); - PyDict_SetItemString(kwargs, "name", name); - PyDict_SetItemString(kwargs, "path", path); + + if (PyDict_SetItemString(kwargs, "name", name) < 0) + return NULL; + if (PyDict_SetItemString(kwargs, "path", path) < 0) + return NULL; error = PyObject_Call(PyExc_ImportError, args, kwargs); if (error != NULL) {