diff --git a/Python/pystate.c b/Python/pystate.c index bba88b76088e71..95638bbe701566 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -3007,6 +3007,7 @@ _PyThreadState_CheckConsistency(PyThreadState *tstate) int _PyThreadState_MustExit(PyThreadState *tstate) { + assert(tstate != NULL); /* bpo-39877: Access _PyRuntime directly rather than using tstate->interp->runtime to support calls from Python daemon threads. After Py_Finalize() has been called, tstate can be a dangling pointer: @@ -3014,7 +3015,7 @@ _PyThreadState_MustExit(PyThreadState *tstate) unsigned long finalizing_id = _PyRuntimeState_GetFinalizingID(&_PyRuntime); PyThreadState *finalizing = _PyRuntimeState_GetFinalizing(&_PyRuntime); if (finalizing == NULL) { - // XXX This isn't completely safe from daemon thraeds, + // XXX This isn't completely safe from daemon threads, // since tstate might be a dangling pointer. finalizing = _PyInterpreterState_GetFinalizing(tstate->interp); finalizing_id = _PyInterpreterState_GetFinalizingID(tstate->interp);