Skip to content

Commit aa9d369

Browse files
committed
Issue python#23960: Cleanup args and kwargs on error in PyErr_SetImportError
Patch by Ofer Schwarz.
2 parents f1e2671 + ec766d3 commit aa9d369

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Python/errors.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -727,19 +727,19 @@ PyErr_SetImportError(PyObject *msg, PyObject *name, PyObject *path)
727727
PyTuple_SET_ITEM(args, 0, msg);
728728

729729
if (PyDict_SetItemString(kwargs, "name", name) < 0)
730-
return NULL;
730+
goto done;
731731
if (PyDict_SetItemString(kwargs, "path", path) < 0)
732-
return NULL;
732+
goto done;
733733

734734
error = PyObject_Call(PyExc_ImportError, args, kwargs);
735735
if (error != NULL) {
736736
PyErr_SetObject((PyObject *)Py_TYPE(error), error);
737737
Py_DECREF(error);
738738
}
739739

740+
done:
740741
Py_DECREF(args);
741742
Py_DECREF(kwargs);
742-
743743
return NULL;
744744
}
745745

0 commit comments

Comments
 (0)