]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-151096: Fix test_embed with split exec prefix (#151288)
authorHarjoth Khara <harjoth.khara@gmail.com>
Mon, 29 Jun 2026 13:28:18 +0000 (06:28 -0700)
committerGitHub <noreply@github.com>
Mon, 29 Jun 2026 13:28:18 +0000 (15:28 +0200)
Lib/test/test_embed.py
Misc/NEWS.d/next/Tests/2026-06-16-05-11-38.gh-issue-151096.Kq3Lp9.rst [new file with mode: 0644]

index 2d1533c46b98f331cedd34a2f8c7eee14dafbc49..d0ac1d1c0cb1a15d0ca5cfe5d41ee144e6cd5ded 100644 (file)
@@ -1458,7 +1458,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
         if prefix is None:
             prefix = config['config']['prefix']
         if exec_prefix is None:
-            exec_prefix = config['config']['prefix']
+            exec_prefix = config['config']['exec_prefix']
         if MS_WINDOWS:
             return config['config']['module_search_paths']
         else:
@@ -1614,8 +1614,10 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
             expected_paths[1 if MS_WINDOWS else 2] = os.path.normpath(
                 os.path.join(exedir, f'{f.read()}\n$'.splitlines()[0]))
         if not MS_WINDOWS:
-            # PREFIX (default) is set when running in build directory
-            prefix = exec_prefix = sys.prefix
+            # PREFIX and EXEC_PREFIX (defaults) are set when running in the
+            # build directory and may differ with --exec-prefix (gh-151096).
+            prefix = sys.prefix
+            exec_prefix = sys.exec_prefix
             # stdlib calculation (/Lib) is not yet supported
             expected_paths[0] = self.module_search_paths(prefix=prefix)[0]
             config.update(prefix=prefix, base_prefix=prefix,
diff --git a/Misc/NEWS.d/next/Tests/2026-06-16-05-11-38.gh-issue-151096.Kq3Lp9.rst b/Misc/NEWS.d/next/Tests/2026-06-16-05-11-38.gh-issue-151096.Kq3Lp9.rst
new file mode 100644 (file)
index 0000000..3251c6f
--- /dev/null
@@ -0,0 +1,2 @@
+Fix ``test_embed`` failing when CPython is configured with a split exec prefix
+(``--exec-prefix`` differing from ``--prefix``).