From 2a8a5a2cbd73c081ea5dad6b99b9736086db8f5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Sun, 4 Jan 2026 14:55:47 +0100 Subject: [PATCH 1/3] gh-143309: fix `test_execve_env_concurrent_mutation_with_fspath_posix` buildbot failure --- Lib/test/test_os/test_os.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_os/test_os.py b/Lib/test/test_os/test_os.py index 67ab945101149d..f1592aa7ee9356 100644 --- a/Lib/test/test_os/test_os.py +++ b/Lib/test/test_os/test_os.py @@ -2627,6 +2627,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. @@ -2648,9 +2650,9 @@ 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. From 448612bd78b45668159948818ea564d09c6be959 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Sun, 4 Jan 2026 16:37:19 +0100 Subject: [PATCH 2/3] fix missing LD_* vars --- Lib/test/test_os/test_os.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_os/test_os.py b/Lib/test/test_os/test_os.py index f1592aa7ee9356..8df5d54b4026d2 100644 --- a/Lib/test/test_os/test_os.py +++ b/Lib/test/test_os/test_os.py @@ -2654,9 +2654,13 @@ def values(self): return VALUES os.execve(args[0], args, MyEnv()) """.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) + # 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) + rc, out, _ = assert_python_ok('-c', code, **env) self.assertEqual(rc, 0) self.assertIn(bytes(message, "ascii"), out) From 7d741e654e8c6c9d9fb7aaad865d77b872f27892 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Sun, 4 Jan 2026 16:37:46 +0100 Subject: [PATCH 3/3] remove redundant check --- Lib/test/test_os/test_os.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Lib/test/test_os/test_os.py b/Lib/test/test_os/test_os.py index 8df5d54b4026d2..82c55c8ba33065 100644 --- a/Lib/test/test_os/test_os.py +++ b/Lib/test/test_os/test_os.py @@ -2660,8 +2660,7 @@ def values(self): return VALUES with os_helper.EnvironmentVarGuard() as env: env.clear() env.update(minimal) - rc, out, _ = assert_python_ok('-c', code, **env) - self.assertEqual(rc, 0) + _, out, _ = assert_python_ok('-c', code, **env) self.assertIn(bytes(message, "ascii"), out) @unittest.skipUnless(sys.platform == "win32", "Win32-specific test")