summaryrefslogtreecommitdiffstats
path: root/Python/pathconfig.c
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-06-20 18:37:27 (GMT)
committerGitHub <noreply@github.com>2022-06-20 18:37:27 (GMT)
commitb8fe3bd1d4be5b7d8e9e20b3c36277117e8f6102 (patch)
treeed83e8794d0c90b59462e926fa0ffd6c50ee642d /Python/pathconfig.c
parent26329e49caaeca1d934016b581aebf25db647a6f (diff)
downloadcpython-b8fe3bd1d4be5b7d8e9e20b3c36277117e8f6102.zip
cpython-b8fe3bd1d4be5b7d8e9e20b3c36277117e8f6102.tar.gz
cpython-b8fe3bd1d4be5b7d8e9e20b3c36277117e8f6102.tar.bz2
gh-91985: Ensure in-tree builds override platstdlib_dir in every path calculation (GH-93641)
(cherry picked from commit 38af903506e9b18c6350c1dadcb489f057713f36) Co-authored-by: neonene <53406459+neonene@users.noreply.github.com>
Diffstat (limited to 'Python/pathconfig.c')
-rw-r--r--Python/pathconfig.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/Python/pathconfig.c b/Python/pathconfig.c
index 4271928..69b7e10 100644
--- a/Python/pathconfig.c
+++ b/Python/pathconfig.c
@@ -36,10 +36,11 @@ typedef struct _PyPathConfig {
wchar_t *program_name;
/* Set by Py_SetPythonHome() or PYTHONHOME environment variable */
wchar_t *home;
+ int _is_python_build;
} _PyPathConfig;
# define _PyPathConfig_INIT \
- {.module_search_path = NULL}
+ {.module_search_path = NULL, ._is_python_build = 0}
_PyPathConfig _Py_path_config = _PyPathConfig_INIT;
@@ -72,6 +73,7 @@ _PyPathConfig_ClearGlobal(void)
CLEAR(calculated_module_search_path);
CLEAR(program_name);
CLEAR(home);
+ _Py_path_config._is_python_build = 0;
#undef CLEAR
@@ -99,15 +101,25 @@ _PyPathConfig_ReadGlobal(PyConfig *config)
} \
} while (0)
+#define COPY_INT(ATTR) \
+ do { \
+ assert(_Py_path_config.ATTR >= 0); \
+ if ((_Py_path_config.ATTR >= 0) && (config->ATTR <= 0)) { \
+ config->ATTR = _Py_path_config.ATTR; \
+ } \
+ } while (0)
+
COPY(prefix);
COPY(exec_prefix);
COPY(stdlib_dir);
COPY(program_name);
COPY(home);
COPY2(executable, program_full_path);
+ COPY_INT(_is_python_build);
// module_search_path must be initialised - not read
#undef COPY
#undef COPY2
+#undef COPY_INT
done:
return status;
@@ -137,14 +149,23 @@ _PyPathConfig_UpdateGlobal(const PyConfig *config)
} \
} while (0)
+#define COPY_INT(ATTR) \
+ do { \
+ if (config->ATTR > 0) { \
+ _Py_path_config.ATTR = config->ATTR; \
+ } \
+ } while (0)
+
COPY(prefix);
COPY(exec_prefix);
COPY(stdlib_dir);
COPY(program_name);
COPY(home);
COPY2(program_full_path, executable);
+ COPY_INT(_is_python_build);
#undef COPY
#undef COPY2
+#undef COPY_INT
PyMem_RawFree(_Py_path_config.module_search_path);
_Py_path_config.module_search_path = NULL;