Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 479054b

Browse files
committed
Issue #18408: Fix PyErr_SetImportError(), handle PyDict_SetItemString() failure
1 parent 8e54b1c commit 479054b

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

Python/errors.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,8 +655,11 @@ PyErr_SetImportError(PyObject *msg, PyObject *name, PyObject *path)
655655

656656
Py_INCREF(msg);
657657
PyTuple_SET_ITEM(args, 0, msg);
658-
PyDict_SetItemString(kwargs, "name", name);
659-
PyDict_SetItemString(kwargs, "path", path);
658+
659+
if (PyDict_SetItemString(kwargs, "name", name) < 0)
660+
return NULL;
661+
if (PyDict_SetItemString(kwargs, "path", path) < 0)
662+
return NULL;
660663

661664
error = PyObject_Call(PyExc_ImportError, args, kwargs);
662665
if (error != NULL) {

0 commit comments

Comments
 (0)