aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2019-09-26 04:01:49 +0200
committerGitHub <noreply@github.com>2019-09-26 04:01:49 +0200
commit49d99f01e6e51acec5ca57a02e857f0796bc418b (patch)
treeb38801ae16e872c8739d3fa4cd03c1e923ff5bbe /Programs
parentbpo-38234: Complete init config documentation (GH-16404) (diff)
downloadcpython-49d99f01e6e51acec5ca57a02e857f0796bc418b.tar.gz
cpython-49d99f01e6e51acec5ca57a02e857f0796bc418b.tar.bz2
cpython-49d99f01e6e51acec5ca57a02e857f0796bc418b.zip
bpo-38234: Fix test_embed.test_init_setpath_config() on FreeBSD (GH-16406)
Explicitly preinitializes with a Python preconfiguration to avoid Py_SetPath() implicit preinitialization with a compat preconfiguration. Fix also test_init_setpath() and test_init_setpythonhome() on macOS: use self.test_exe as the executable (and base_executable), rather than shutil.which('python3').
Diffstat (limited to 'Programs')
-rw-r--r--Programs/_testembed.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/Programs/_testembed.c b/Programs/_testembed.c
index 14fca24f318..83c266b885a 100644
--- a/Programs/_testembed.c
+++ b/Programs/_testembed.c
@@ -1448,6 +1448,17 @@ static int test_init_setpath(void)
static int test_init_setpath_config(void)
{
+ PyStatus status;
+ PyPreConfig preconfig;
+ PyPreConfig_InitPythonConfig(&preconfig);
+
+ /* Explicitly preinitializes with Python preconfiguration to avoid
+ Py_SetPath() implicit preinitialization with compat preconfiguration. */
+ status = Py_PreInitialize(&preconfig);
+ if (PyStatus_Exception(status)) {
+ Py_ExitStatusException(status);
+ }
+
char *env = getenv("TESTPATH");
if (!env) {
fprintf(stderr, "missing TESTPATH env var\n");
@@ -1462,7 +1473,6 @@ static int test_init_setpath_config(void)
PyMem_RawFree(path);
putenv("TESTPATH=");
- PyStatus status;
PyConfig config;
status = PyConfig_InitPythonConfig(&config);