diff --git a/Python/pystate.c b/Python/pystate.c index 15761e7da90..8077a3ee7ab 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -532,6 +532,7 @@ PyState_RemoveModule(struct PyModuleDef* def) Py_FatalError("PyState_RemoveModule: Module index out of bounds."); return -1; } + Py_INCREF(Py_None); return PyList_SetItem(state->modules_by_index, index, Py_None); }