summaryrefslogtreecommitdiffstats
path: root/PC
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 /PC
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 'PC')
-rw-r--r--PC/getpathp.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/PC/getpathp.c b/PC/getpathp.c
index fa687b7..df4cb0a 100644
--- a/PC/getpathp.c
+++ b/PC/getpathp.c
@@ -553,8 +553,7 @@ get_program_full_path(const _PyCoreConfig *core_config,
static int
-read_pth_file(_PyPathConfig *config, wchar_t *prefix, const wchar_t *path,
- int *isolated, int *nosite)
+read_pth_file(_PyPathConfig *config, wchar_t *prefix, const wchar_t *path)
{
FILE *sp_file = _Py_wfopen(path, L"r");
if (sp_file == NULL) {
@@ -563,8 +562,8 @@ read_pth_file(_PyPathConfig *config, wchar_t *prefix, const wchar_t *path,
wcscpy_s(prefix, MAXPATHLEN+1, path);
reduce(prefix);
- *isolated = 1;
- *nosite = 1;
+ config->isolated = 1;
+ config->no_site_import = 1;
size_t bufsiz = MAXPATHLEN;
size_t prefixlen = wcslen(prefix);
@@ -589,9 +588,10 @@ read_pth_file(_PyPathConfig *config, wchar_t *prefix, const wchar_t *path,
}
if (strcmp(line, "import site") == 0) {
- *nosite = 0;
+ config->no_site_import = 0;
continue;
- } else if (strncmp(line, "import ", 7) == 0) {
+ }
+ else if (strncmp(line, "import ", 7) == 0) {
Py_FatalError("only 'import site' is supported in ._pth file");
}
@@ -680,11 +680,7 @@ calculate_pth_file(_PyPathConfig *config, wchar_t *prefix)
return 0;
}
- /* FIXME, bpo-32030: Global configuration variables should not be modified
- here, _PyPathConfig_Init() is called early in Python initialization:
- see pymain_cmdline(). */
- return read_pth_file(config, prefix, spbuffer,
- &Py_IsolatedFlag, &Py_NoSiteFlag);
+ return read_pth_file(config, prefix, spbuffer);
}