Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fd23cfa

Browse files
authored
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.
1 parent fe13883 commit fd23cfa

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

Python/pylifecycle.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ static void call_ll_exitfuncs(void);
6969

7070
int _Py_UnhandledKeyboardInterrupt = 0;
7171
_PyRuntimeState _PyRuntime = _PyRuntimeState_INIT;
72+
static int runtime_initialized = 0;
7273

7374
_PyInitError
7475
_PyRuntime_Initialize(void)
@@ -79,11 +80,10 @@ _PyRuntime_Initialize(void)
7980
every Py_Initialize() call, but doing so breaks the runtime.
8081
This is because the runtime state is not properly finalized
8182
currently. */
82-
static int initialized = 0;
83-
if (initialized) {
83+
if (runtime_initialized) {
8484
return _Py_INIT_OK();
8585
}
86-
initialized = 1;
86+
runtime_initialized = 1;
8787

8888
return _PyRuntimeState_Init(&_PyRuntime);
8989
}
@@ -92,6 +92,7 @@ void
9292
_PyRuntime_Finalize(void)
9393
{
9494
_PyRuntimeState_Fini(&_PyRuntime);
95+
runtime_initialized = 0;
9596
}
9697

9798
int

0 commit comments

Comments
 (0)