bpo-33932: Calling Py_Initialize() twice does nothing (GH-7845)
Calling Py_Initialize() twice does nothing, instead of failing with a
fatal error: restore the Python 3.6 behaviour.
(cherry picked from commit 209abf746985526bce255e2fba97d3246924885d)
Co-authored-by: Victor Stinner <vstinner@redhat.com>
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index 2ef96f8..fdb759f 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -895,6 +895,11 @@
_PyInitError
_Py_InitializeEx_Private(int install_sigs, int install_importlib)
{
+ if (_PyRuntime.initialized) {
+ /* bpo-33932: Calling Py_Initialize() twice does nothing. */
+ return _Py_INIT_OK();
+ }
+
_PyCoreConfig config = _PyCoreConfig_INIT;
_PyInitError err;