summaryrefslogtreecommitdiffstats
path: root/Python/pylifecycle.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2018-07-21 00:06:16 (GMT)
committerGitHub <noreply@github.com>2018-07-21 00:06:16 (GMT)
commitb1147e43daeb3c51a63056b489e8d868404d4e22 (patch)
treec5716fcfca0f90abbc21b291cd51b0ae022759c4 /Python/pylifecycle.c
parent94487d45707772723ef19e86700a40a12743baa1 (diff)
downloadcpython-b1147e43daeb3c51a63056b489e8d868404d4e22.zip
cpython-b1147e43daeb3c51a63056b489e8d868404d4e22.tar.gz
cpython-b1147e43daeb3c51a63056b489e8d868404d4e22.tar.bz2
bpo-34170: Rework _PyCoreConfig_Read() to avoid side effect (GH-8353)
Rework _PyCoreConfig_Read() function which *reads* core configuration to not *modify* the path configuration. A new _PyCoreConfig_SetPathConfig() function now recreates the path configuration from the core configuration. This function is now called very late in _Py_InitializeCore(), just before calling initimport(). Changes: * Add _PyCoreConfig.dll_path * Py_SetPath() now fails with a fatal python error on memory allocation failure. * Rename _PyPathConfig_Calculate() to _PyPathConfig_Calculate_impl() * Replace _PyPathConfig_Init() with _PyPathConfig_Calculate(): the function now requires a _PyPathConfig * Add _PyPathConfig_SetGlobal() to set the _Py_path_config global variable. * Add _PyCoreConfig_InitPathConfig(): compute the path configuration * Add _PyCoreConfig_SetPathConfig(): set path configuration from core configuration * Rename wstrlist_append() to _Py_wstrlist_append() * _Py_wstrlist_append() now handles integer overflow.
Diffstat (limited to 'Python/pylifecycle.c')
-rw-r--r--Python/pylifecycle.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index 64fa1e5..325f423 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -759,6 +759,13 @@ _Py_InitializeCore(const _PyCoreConfig *core_config)
if (!_PyContext_Init())
return _Py_INIT_ERR("can't init context");
+ if (!core_config->_disable_importlib) {
+ err = _PyCoreConfig_SetPathConfig(core_config);
+ if (_Py_INIT_FAILED(err)) {
+ return err;
+ }
+ }
+
/* This call sets up builtin and frozen import support */
if (!interp->core_config._disable_importlib) {
err = initimport(interp, sysmod);