Unverified Kaydet (Commit) fd23cfa4 authored tarafından Victor Stinner's avatar Victor Stinner Kaydeden (comit) GitHub

bpo-35388: Fix _PyRuntime_Finalize() (GH-12443)

Calling _PyRuntime_Initialize() after _PyRuntime_Finalize() now re-initializes
_PyRuntime structure. Previously, _PyRuntime_Initialize() did
nothing in that case.
üst fe13883f
...@@ -69,6 +69,7 @@ static void call_ll_exitfuncs(void); ...@@ -69,6 +69,7 @@ static void call_ll_exitfuncs(void);
int _Py_UnhandledKeyboardInterrupt = 0; int _Py_UnhandledKeyboardInterrupt = 0;
_PyRuntimeState _PyRuntime = _PyRuntimeState_INIT; _PyRuntimeState _PyRuntime = _PyRuntimeState_INIT;
static int runtime_initialized = 0;
_PyInitError _PyInitError
_PyRuntime_Initialize(void) _PyRuntime_Initialize(void)
...@@ -79,11 +80,10 @@ _PyRuntime_Initialize(void) ...@@ -79,11 +80,10 @@ _PyRuntime_Initialize(void)
every Py_Initialize() call, but doing so breaks the runtime. every Py_Initialize() call, but doing so breaks the runtime.
This is because the runtime state is not properly finalized This is because the runtime state is not properly finalized
currently. */ currently. */
static int initialized = 0; if (runtime_initialized) {
if (initialized) {
return _Py_INIT_OK(); return _Py_INIT_OK();
} }
initialized = 1; runtime_initialized = 1;
return _PyRuntimeState_Init(&_PyRuntime); return _PyRuntimeState_Init(&_PyRuntime);
} }
...@@ -92,6 +92,7 @@ void ...@@ -92,6 +92,7 @@ void
_PyRuntime_Finalize(void) _PyRuntime_Finalize(void)
{ {
_PyRuntimeState_Fini(&_PyRuntime); _PyRuntimeState_Fini(&_PyRuntime);
runtime_initialized = 0;
} }
int int
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment