summaryrefslogtreecommitdiffstats
path: root/Programs
diff options
context:
space:
mode:
authorneonene <53406459+neonene@users.noreply.github.com>2022-06-16 21:41:57 (GMT)
committerGitHub <noreply@github.com>2022-06-16 21:41:57 (GMT)
commit38af903506e9b18c6350c1dadcb489f057713f36 (patch)
treefcc091611248f910d20f853e68f9f392e7b68696 /Programs
parentf8e576be0a7cd38f753f31cf4178db81a602fc32 (diff)
downloadcpython-38af903506e9b18c6350c1dadcb489f057713f36.zip
cpython-38af903506e9b18c6350c1dadcb489f057713f36.tar.gz
cpython-38af903506e9b18c6350c1dadcb489f057713f36.tar.bz2
gh-91985: Ensure in-tree builds override platstdlib_dir in every path calculation (GH-93641)
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},