@@ -2627,6 +2627,8 @@ def test_execve_invalid_env(self):
26272627 # See https://github.com/python/cpython/issues/137934 and the other
26282628 # related issues for the reason why we cannot test this on Windows.
26292629 @unittest .skipIf (os .name == "nt" , "POSIX-specific test" )
2630+ @unittest .skipUnless (unix_shell and os .path .exists (unix_shell ),
2631+ "requires a shell" )
26302632 def test_execve_env_concurrent_mutation_with_fspath_posix (self ):
26312633 # Prevent crash when mutating environment during parsing.
26322634 # Regression test for https://github.com/python/cpython/issues/143309.
@@ -2648,14 +2650,17 @@ def __len__(self): return 1
26482650 def keys(self): return KEYS
26492651 def values(self): return VALUES
26502652
2651- args = [sys.executable , '-c', "print( {message!r})" ]
2653+ args = [{unix_shell!r} , '-c', 'echo \" {message!s} \" ' ]
26522654 os.execve(args[0], args, MyEnv())
2653- """ .format (message = message )
2655+ """ .format (unix_shell = unix_shell , message = message )
26542656
2655- # Use '__cleanenv' to signal to assert_python_ok() not
2656- # to do a copy of os.environ on its own.
2657- rc , out , _ = assert_python_ok ('-c' , code , __cleanenv = True )
2658- self .assertEqual (rc , 0 )
2657+ # Make sure to forward "LD_*" variables so that assert_python_ok()
2658+ # can run correctly.
2659+ minimal = {k : v for k , v in os .environ .items () if k .startswith ("LD_" )}
2660+ with os_helper .EnvironmentVarGuard () as env :
2661+ env .clear ()
2662+ env .update (minimal )
2663+ _ , out , _ = assert_python_ok ('-c' , code , ** env )
26592664 self .assertIn (bytes (message , "ascii" ), out )
26602665
26612666 @unittest .skipUnless (sys .platform == "win32" , "Win32-specific test" )
0 commit comments