diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index 048c2b283d4..ec26824f839 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -302,9 +302,11 @@ initimport(PyInterpreterState *interp, PyObject *sysmod) /* Install importlib as the implementation of import */ value = PyObject_CallMethod(importlib, "_install", "OO", sysmod, impmod); - if (value != NULL) + if (value != NULL) { + Py_DECREF(value); value = PyObject_CallMethod(importlib, "_install_external_importers", ""); + } if (value == NULL) { PyErr_Print(); Py_FatalError("Py_Initialize: importlib install failed"); @@ -325,6 +327,7 @@ initexternalimport(PyInterpreterState *interp) PyErr_Print(); Py_FatalError("Py_EndInitialization: external importer setup failed"); } + Py_DECREF(value); }