summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2017-11-30 17:03:55 (GMT)
committerGitHub <noreply@github.com>2017-11-30 17:03:55 (GMT)
commitbc8ac6b00efcb3c601224b73f64071281f434bcd (patch)
treeda16aa1cf4adcc615afcb825ae0204e325cc1339
parent0efc0249ca1fd0675098957407fbba2c0f6949ce (diff)
downloadcpython-bc8ac6b00efcb3c601224b73f64071281f434bcd.zip
cpython-bc8ac6b00efcb3c601224b73f64071281f434bcd.tar.gz
cpython-bc8ac6b00efcb3c601224b73f64071281f434bcd.tar.bz2
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.
-rw-r--r--Python/pylifecycle.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index 01f314e..f0a49f9 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -961,28 +961,35 @@ _Py_InitializeEx_Private(int install_sigs, int install_importlib)
_PyMainInterpreterConfig config = _PyMainInterpreterConfig_INIT;
_PyInitError err;
- /* TODO: Moar config options! */
core_config.ignore_environment = Py_IgnoreEnvironmentFlag;
core_config._disable_importlib = !install_importlib;
config.install_signal_handlers = install_sigs;
err = _Py_InitializeCore(&core_config);
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);
if (_Py_INIT_FAILED(err)) {
- return err;
+ goto done;
}
err = _Py_InitializeMainInterpreter(&config);
if (_Py_INIT_FAILED(err)) {
- return err;
+ goto done;
}
- return _Py_INIT_OK();
+ err = _Py_INIT_OK();
+
+done:
+ _PyMainInterpreterConfig_Clear(&config);
+ return err;
}