From ca7ead906088fd32924ea19bf06170d4173d4f88 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 19 Mar 2019 17:48:18 +0100 Subject: [PATCH] bpo-35388: Fix _PyRuntime_Finalize() _PyRuntime_Initialize() after _PyRuntime_Finalize() now re-initialize _PyRuntime structure. Previously, _PyRuntime_Initialize() did nothing. --- Python/pylifecycle.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index 49a2f18e49fa1dc..df9570b2e487758 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -69,6 +69,7 @@ static void call_ll_exitfuncs(void); int _Py_UnhandledKeyboardInterrupt = 0; _PyRuntimeState _PyRuntime = _PyRuntimeState_INIT; +static int runtime_initialized = 0; _PyInitError _PyRuntime_Initialize(void) @@ -79,11 +80,10 @@ _PyRuntime_Initialize(void) every Py_Initialize() call, but doing so breaks the runtime. This is because the runtime state is not properly finalized currently. */ - static int initialized = 0; - if (initialized) { + if (runtime_initialized) { return _Py_INIT_OK(); } - initialized = 1; + runtime_initialized = 1; return _PyRuntimeState_Init(&_PyRuntime); } @@ -92,6 +92,7 @@ void _PyRuntime_Finalize(void) { _PyRuntimeState_Fini(&_PyRuntime); + runtime_initialized = 0; } int