bpo-32030: Fix _Py_InitializeEx_Private() (#4649) · python/cpython@bc8ac6b (original) (raw)

Original file line number Diff line number Diff line change
@@ -961,28 +961,35 @@ _Py_InitializeEx_Private(int install_sigs, int install_importlib)
961 961 _PyMainInterpreterConfig config = _PyMainInterpreterConfig_INIT;
962 962 _PyInitError err;
963 963
964 -/* TODO: Moar config options! */
965 964 core_config.ignore_environment = Py_IgnoreEnvironmentFlag;
966 965 core_config._disable_importlib = !install_importlib;
967 966 config.install_signal_handlers = install_sigs;
968 967
969 968 err = _Py_InitializeCore(&core_config);
970 969 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;
972 976 }
973 977
974 -/* TODO: Print any exceptions raised by these operations */
975 978 err = _PyMainInterpreterConfig_Read(&config);
976 979 if (_Py_INIT_FAILED(err)) {
977 -return err;
980 +goto done;
978 981 }
979 982
980 983 err = _Py_InitializeMainInterpreter(&config);
981 984 if (_Py_INIT_FAILED(err)) {
982 -return err;
985 +goto done;
983 986 }
984 987
985 -return _Py_INIT_OK();
988 +err = _Py_INIT_OK();
989 +
990 +done:
991 +_PyMainInterpreterConfig_Clear(&config);
992 +return err;
986 993 }
987 994
988 995