summaryrefslogtreecommitdiffstats
path: root/Programs
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 /Programs
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 'Programs')
-rw-r--r--Programs/_testembed.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/Programs/_testembed.c b/Programs/_testembed.c
index 9d3d0cb..542e469 100644
--- a/Programs/_testembed.c
+++ b/Programs/_testembed.c
@@ -1550,6 +1550,46 @@ static int test_init_setpythonhome(void)
}
+static int test_init_is_python_build(void)
+{
+ // gh-91985: in-tree builds fail to check for build directory landmarks
+ // under the effect of 'home' or PYTHONHOME environment variable.
+ char *env = getenv("TESTHOME");
+ if (!env) {
+ error("missing TESTHOME env var");
+ return 1;
+ }
+ wchar_t *home = Py_DecodeLocale(env, NULL);
+ if (home == NULL) {
+ error("failed to decode TESTHOME");
+ return 1;
+ }
+
+ PyConfig config;
+ _PyConfig_InitCompatConfig(&config);
+ config_set_program_name(&config);
+ config_set_string(&config, &config.home, home);
+ PyMem_RawFree(home);
+ putenv("TESTHOME=");
+
+ // Use an impossible value so we can detect whether it isn't updated
+ // during initialization.
+ config._is_python_build = INT_MAX;
+ env = getenv("NEGATIVE_ISPYTHONBUILD");
+ if (env && strcmp(env, "0") != 0) {
+ config._is_python_build++;
+ }
+ init_from_config_clear(&config);
+ Py_Finalize();
+ // Second initialization
+ config._is_python_build = -1;
+ init_from_config_clear(&config);
+ dump_config(); // home and _is_python_build are cached in _Py_path_config
+ Py_Finalize();
+ return 0;
+}
+
+
static int test_init_warnoptions(void)
{
putenv("PYTHONWARNINGS=ignore:::env1,ignore:::env2");
@@ -1965,6 +2005,7 @@ static struct TestCase TestCases[] = {
{"test_init_setpath", test_init_setpath},
{"test_init_setpath_config", test_init_setpath_config},
{"test_init_setpythonhome", test_init_setpythonhome},
+ {"test_init_is_python_build", test_init_is_python_build},
{"test_init_warnoptions", test_init_warnoptions},
{"test_init_set_config", test_init_set_config},
{"test_run_main", test_run_main},