summaryrefslogtreecommitdiffstats
path: root/Modules/main.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 /Modules/main.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 'Modules/main.c')
-rw-r--r--Modules/main.c20
1 files changed, 5 insertions, 15 deletions
diff --git a/Modules/main.c b/Modules/main.c
index 5166e74..2b68185 100644
--- a/Modules/main.c
+++ b/Modules/main.c
@@ -1953,19 +1953,9 @@ pymain_read_conf_impl(_PyMain *pymain, _Py_CommandLineDetails *cmdline)
return -1;
}
- /* On Windows, _PyPathConfig_Init() modifies Py_IsolatedFlag and
- Py_NoSiteFlag variables if a "._pth" file is found. */
- int init_isolated = Py_IsolatedFlag;
- int init_no_site = Py_NoSiteFlag;
- Py_IsolatedFlag = cmdline->isolated;
- Py_NoSiteFlag = cmdline->no_site_import;
-
- err = _PyCoreConfig_Read(config);
-
- cmdline->isolated = Py_IsolatedFlag;
- cmdline->no_site_import = Py_NoSiteFlag;
- Py_IsolatedFlag = init_isolated;
- Py_NoSiteFlag = init_no_site;
+ err = _PyCoreConfig_Read(config,
+ &cmdline->isolated,
+ &cmdline->no_site_import);
if (_Py_INIT_FAILED(err)) {
pymain->err = err;
@@ -2116,7 +2106,7 @@ config_init_locale(_PyCoreConfig *config)
*/
_PyInitError
-_PyCoreConfig_Read(_PyCoreConfig *config)
+_PyCoreConfig_Read(_PyCoreConfig *config, int *isolated, int *no_site_import)
{
_PyInitError err;
@@ -2161,7 +2151,7 @@ _PyCoreConfig_Read(_PyCoreConfig *config)
}
if (!config->_disable_importlib) {
- err = _PyCoreConfig_InitPathConfig(config);
+ err = _PyCoreConfig_InitPathConfig(config, isolated, no_site_import);
if (_Py_INIT_FAILED(err)) {
return err;
}