summaryrefslogtreecommitdiffstats
path: root/Python/pylifecycle.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2019-03-19 23:03:01 (GMT)
committerGitHub <noreply@github.com>2019-03-19 23:03:01 (GMT)
commitfd23cfa464ab93273370475900819c1ea37c852f (patch)
treed0ea39fe76e18a937db90974781ab99b1e2c9db7 /Python/pylifecycle.c
parentfe13883f01da855967403acab77e0f16707a56cb (diff)
downloadcpython-fd23cfa464ab93273370475900819c1ea37c852f.zip
cpython-fd23cfa464ab93273370475900819c1ea37c852f.tar.gz
cpython-fd23cfa464ab93273370475900819c1ea37c852f.tar.bz2
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.
Diffstat (limited to 'Python/pylifecycle.c')
-rw-r--r--Python/pylifecycle.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index 49a2f18..df9570b 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