diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index 751c4d6d1d..6719fa22b3 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -1289,6 +1289,10 @@ Py_FinalizeEx(void) } #endif /* Py_TRACE_REFS */ + if (tstate != interp->tstate_head || tstate->next != NULL) { + Py_FatalError("Py_EndInterpreter: not the last thread"); + } + /* Clear interpreter state and all thread states. */ PyInterpreterState_Clear(interp);