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.
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index 958219b..9bf0ebd 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -892,6 +892,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;