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.
This commit is contained in:
Victor Stinner 2017-11-30 18:03:55 +01:00 committed by GitHub
parent 0efc0249ca
commit bc8ac6b00e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 6 deletions

View File

@ -961,28 +961,35 @@ _Py_InitializeEx_Private(int install_sigs, int install_importlib)
_PyMainInterpreterConfig config = _PyMainInterpreterConfig_INIT; _PyMainInterpreterConfig config = _PyMainInterpreterConfig_INIT;
_PyInitError err; _PyInitError err;
/* TODO: Moar config options! */
core_config.ignore_environment = Py_IgnoreEnvironmentFlag; core_config.ignore_environment = Py_IgnoreEnvironmentFlag;
core_config._disable_importlib = !install_importlib; core_config._disable_importlib = !install_importlib;
config.install_signal_handlers = install_sigs; config.install_signal_handlers = install_sigs;
err = _Py_InitializeCore(&core_config); err = _Py_InitializeCore(&core_config);
if (_Py_INIT_FAILED(err)) { if (_Py_INIT_FAILED(err)) {
return err; goto done;
}
err = _PyMainInterpreterConfig_ReadEnv(&config);
if (_Py_INIT_FAILED(err)) {
goto done;
} }
/* TODO: Print any exceptions raised by these operations */
err = _PyMainInterpreterConfig_Read(&config); err = _PyMainInterpreterConfig_Read(&config);
if (_Py_INIT_FAILED(err)) { if (_Py_INIT_FAILED(err)) {
return err; goto done;
} }
err = _Py_InitializeMainInterpreter(&config); err = _Py_InitializeMainInterpreter(&config);
if (_Py_INIT_FAILED(err)) { if (_Py_INIT_FAILED(err)) {
return err; goto done;
} }
return _Py_INIT_OK(); err = _Py_INIT_OK();
done:
_PyMainInterpreterConfig_Clear(&config);
return err;
} }