Skip to content

Commit c944ef8

Browse files
committed
remove test crashing on Windows
1 parent 7b6e2db commit c944ef8

File tree

1 file changed

+2
-43
lines changed

1 file changed

+2
-43
lines changed

Lib/test/test_os/test_os.py

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2624,6 +2624,8 @@ def test_execve_invalid_env(self):
26242624
with self.assertRaises(ValueError):
26252625
os.execve(args[0], args, newenv)
26262626

2627+
# See https://github.com/python/cpython/issues/137934 and the other
2628+
# related issues for the reason why we cannot test this on Windows.
26272629
@unittest.skipIf(os.name == "nt", "POSIX-specific test")
26282630
def test_execve_env_concurrent_mutation_with_fspath_posix(self):
26292631
# Prevent crash when mutating environment during parsing.
@@ -2656,49 +2658,6 @@ def values(self): return VALUES
26562658
self.assertEqual(rc, 0)
26572659
self.assertIn(bytes(message, "ascii"), out)
26582660

2659-
@unittest.skipUnless(os.name == "nt", "Windows-specific test")
2660-
def test_execve_env_concurrent_mutation_with_fspath_windows(self):
2661-
# See https://github.com/python/cpython/pull/143314
2662-
# to understand why we cannot use spaces in strings
2663-
# when using subprocess and os.execve() on Windows.
2664-
message = "123456"
2665-
2666-
code = """
2667-
import os, sys
2668-
2669-
assert "SYSTEMROOT" in os.environ, list(os.environ.keys())
2670-
assert os.environ["SYSTEMROOT"] == {SYSTEMROOT!r}, (
2671-
repr(os.environ["SYSTEMROOT"]),
2672-
repr({SYSTEMROOT!r}),
2673-
)
2674-
2675-
class MyPath:
2676-
def __fspath__(self):
2677-
mutated1.clear()
2678-
mutated2.clear()
2679-
return b"pwn"
2680-
2681-
# Python requires "SYSTEMROOT" to be set so we make sure
2682-
# that the side effect happens afterwards.
2683-
mutated1 = KEYS = ["SYSTEMROOT", MyPath()]
2684-
mutated2 = VALUES = [{SYSTEMROOT!r}, b"ed"]
2685-
2686-
class MyEnv:
2687-
def __getitem__(self): raise RuntimeError("must not be called")
2688-
def __len__(self): return 2
2689-
def keys(self): return KEYS
2690-
def values(self): return VALUES
2691-
2692-
args = [sys.executable, '-c', "print({message!r})"]
2693-
os.execve(args[0], args, MyEnv())
2694-
""".format(message=message, SYSTEMROOT=os.environ["SYSTEMROOT"])
2695-
2696-
# Use '__cleanenv' to signal to assert_python_ok() not
2697-
# to do a copy of os.environ on its own.
2698-
rc, out, _ = assert_python_ok('-c', code, __cleanenv=True)
2699-
self.assertEqual(rc, 0)
2700-
self.assertIn(bytes(message, "ascii"), out)
2701-
27022661
@unittest.skipUnless(sys.platform == "win32", "Win32-specific test")
27032662
def test_execve_with_empty_path(self):
27042663
# bpo-32890: Check GetLastError() misuse

0 commit comments

Comments
 (0)