summaryrefslogtreecommitdiffstats
path: root/Python/pathconfig.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2018-07-21 01:54:20 (GMT)
committerGitHub <noreply@github.com>2018-07-21 01:54:20 (GMT)
commitf2626ce6d4136f13a506e34ca8631ff2eab85fd9 (patch)
tree4ff9ea663d47622f013a6f42585641585471af43 /Python/pathconfig.c
parentc884616390f990a58fe337376904530a48a0e833 (diff)
downloadcpython-f2626ce6d4136f13a506e34ca8631ff2eab85fd9.zip
cpython-f2626ce6d4136f13a506e34ca8631ff2eab85fd9.tar.gz
cpython-f2626ce6d4136f13a506e34ca8631ff2eab85fd9.tar.bz2
bpo-34170: _PyCoreConfig_Read() leaves Py_IsolatedFlag unchanged (GH-8361)
* _PyCoreConfig_Read() no longer directly modifies Py_IsolatedFlag and Py_NoSiteFlag global configuration flags. The function now requires two pointers to integer, so these flags can be set later, to avoid side effets in _PyCoreConfig_Read(). * pathconfig_global_init() now leaves Py_IsolatedFlag and Py_NoSiteFlag unchanged. * Fix pathconfig_global_init(): avoid computing the path configuration twice, use _PyCoreConfig_SetPathConfig().
Diffstat (limited to 'Python/pathconfig.c')
-rw-r--r--Python/pathconfig.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/Python/pathconfig.c b/Python/pathconfig.c
index e987df1..1f6177f 100644
--- a/Python/pathconfig.c
+++ b/Python/pathconfig.c
@@ -283,7 +283,8 @@ core_config_init_module_search_paths(_PyCoreConfig *config,
_PyInitError
-_PyCoreConfig_InitPathConfig(_PyCoreConfig *config)
+_PyCoreConfig_InitPathConfig(_PyCoreConfig *config,
+ int *isolated, int *no_site_import)
{
_PyPathConfig path_config = _PyPathConfig_INIT;
_PyInitError err;
@@ -344,6 +345,13 @@ _PyCoreConfig_InitPathConfig(_PyCoreConfig *config)
}
}
+ if (path_config.isolated != -1 && isolated != NULL) {
+ *isolated = path_config.isolated;
+ }
+ if (path_config.no_site_import != -1 && no_site_import != NULL) {
+ *no_site_import = path_config.no_site_import;
+ }
+
_PyPathConfig_Clear(&path_config);
return _Py_INIT_OK();
@@ -365,30 +373,25 @@ pathconfig_global_init(void)
}
_PyInitError err;
- _PyPathConfig path_config = _PyPathConfig_INIT;
_PyCoreConfig config = _PyCoreConfig_INIT;
- err = _PyCoreConfig_Read(&config);
+ /* Py_IsolatedFlag and Py_NoSiteFlag are left unchanged: pass NULL.
+ _PyCoreConfig_InitPathConfig() will be called later and will set
+ these flags. */
+ err = _PyCoreConfig_Read(&config, NULL, NULL);
if (_Py_INIT_FAILED(err)) {
goto error;
}
- err = _PyPathConfig_Calculate(&path_config, &config);
+ err = _PyCoreConfig_SetPathConfig(&config);
if (_Py_INIT_FAILED(err)) {
goto error;
}
- err = _PyPathConfig_SetGlobal(&path_config);
- if (_Py_INIT_FAILED(err)) {
- goto error;
- }
-
- _PyPathConfig_Clear(&path_config);
_PyCoreConfig_Clear(&config);
return;
error:
- _PyPathConfig_Clear(&path_config);
_PyCoreConfig_Clear(&config);
_Py_FatalInitError(err);
}