Issue #18408: Fix PyErr_SetImportError(), handle PyDict_SetItemString() failure

This commit is contained in:
Victor Stinner 2013-07-17 21:54:25 +02:00
parent 8e54b1c448
commit 479054bca7
1 changed files with 5 additions and 2 deletions

View File

@ -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) {