https://github.com/python/cpython/commit/d0e9f4445a0d9039e1a2367ecee376b4b3ba7593
commit: d0e9f4445a0d9039e1a2367ecee376b4b3ba7593
branch: 3.14
author: Miss Islington (bot) <[email protected]>
committer: picnixz <[email protected]>
date: 2026-01-05T00:11:59+01:00
summary:

[3.14] gh-143309: fix `test_execve_env_concurrent_mutation_with_fspath_posix` 
buildbot failure (GH-143415) (#143419)

gh-143309: fix `test_execve_env_concurrent_mutation_with_fspath_posix` buildbot 
failure (GH-143415)
(cherry picked from commit c99f7667436d8978b4077704333e2a351f2a026f)

Co-authored-by: Bénédikt Tran <[email protected]>

files:
M Lib/test/test_os.py

diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index 5de3bb7c997c24..7a28e7b4598c16 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -2420,6 +2420,8 @@ def test_execve_invalid_env(self):
     # See https://github.com/python/cpython/issues/137934 and the other
     # related issues for the reason why we cannot test this on Windows.
     @unittest.skipIf(os.name == "nt", "POSIX-specific test")
+    @unittest.skipUnless(unix_shell and os.path.exists(unix_shell),
+                        "requires a shell")
     def test_execve_env_concurrent_mutation_with_fspath_posix(self):
         # Prevent crash when mutating environment during parsing.
         # Regression test for https://github.com/python/cpython/issues/143309.
@@ -2441,14 +2443,17 @@ def __len__(self): return 1
             def keys(self): return KEYS
             def values(self): return VALUES
 
-        args = [sys.executable, '-c', "print({message!r})"]
+        args = [{unix_shell!r}, '-c', 'echo \"{message!s}\"']
         os.execve(args[0], args, MyEnv())
-        """.format(message=message)
+        """.format(unix_shell=unix_shell, message=message)
 
-        # Use '__cleanenv' to signal to assert_python_ok() not
-        # to do a copy of os.environ on its own.
-        rc, out, _ = assert_python_ok('-c', code, __cleanenv=True)
-        self.assertEqual(rc, 0)
+        # Make sure to forward "LD_*" variables so that assert_python_ok()
+        # can run correctly.
+        minimal = {k: v for k, v in os.environ.items() if k.startswith("LD_")}
+        with os_helper.EnvironmentVarGuard() as env:
+            env.clear()
+            env.update(minimal)
+            _, out, _ = assert_python_ok('-c', code, **env)
         self.assertIn(bytes(message, "ascii"), out)
 
     @unittest.skipUnless(sys.platform == "win32", "Win32-specific test")

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to