Skip to content

Commit bc8ac6b

Browse files
authored
bpo-32030: Fix _Py_InitializeEx_Private() (#4649)
_Py_InitializeEx_Private() now calls _PyMainInterpreterConfig_ReadEnv() to read environment variables PYTHONHOME and PYTHONPATH, and set the program name.
1 parent 0efc024 commit bc8ac6b

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

Python/pylifecycle.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -961,28 +961,35 @@ _Py_InitializeEx_Private(int install_sigs, int install_importlib)
961961
_PyMainInterpreterConfig config = _PyMainInterpreterConfig_INIT;
962962
_PyInitError err;
963963

964-
/* TODO: Moar config options! */
965964
core_config.ignore_environment = Py_IgnoreEnvironmentFlag;
966965
core_config._disable_importlib = !install_importlib;
967966
config.install_signal_handlers = install_sigs;
968967

969968
err = _Py_InitializeCore(&core_config);
970969
if (_Py_INIT_FAILED(err)) {
971-
return err;
970+
goto done;
971+
}
972+
973+
err = _PyMainInterpreterConfig_ReadEnv(&config);
974+
if (_Py_INIT_FAILED(err)) {
975+
goto done;
972976
}
973977

974-
/* TODO: Print any exceptions raised by these operations */
975978
err = _PyMainInterpreterConfig_Read(&config);
976979
if (_Py_INIT_FAILED(err)) {
977-
return err;
980+
goto done;
978981
}
979982

980983
err = _Py_InitializeMainInterpreter(&config);
981984
if (_Py_INIT_FAILED(err)) {
982-
return err;
985+
goto done;
983986
}
984987

985-
return _Py_INIT_OK();
988+
err = _Py_INIT_OK();
989+
990+
done:
991+
_PyMainInterpreterConfig_Clear(&config);
992+
return err;
986993
}
987994

988995

0 commit comments

Comments
 (0)