From d59e8f97c9cb1f8bb9035c36b15e4e77f02084e8 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 24 Jun 2020 02:33:13 +0200 Subject: [PATCH] bpo-40521: Fix _PyContext_Fini() Only clear _token_missing in the main interpreter. --- Python/context.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Python/context.c b/Python/context.c index dc340718847507..15d8b8ea4b9b61 100644 --- a/Python/context.c +++ b/Python/context.c @@ -1302,7 +1302,9 @@ _PyContext_ClearFreeList(PyThreadState *tstate) void _PyContext_Fini(PyThreadState *tstate) { - Py_CLEAR(_token_missing); + if (_Py_IsMainInterpreter(tstate)) { + Py_CLEAR(_token_missing); + } _PyContext_ClearFreeList(tstate); #ifdef Py_DEBUG struct _Py_context_state *state = &tstate->interp->context;