From d7e2b00a3311b6718dc4d2d37aed548047150b29 Mon Sep 17 00:00:00 2001 From: AAyberkU <97833630+AAyberkU@users.noreply.github.com> Date: Sun, 22 Nov 2026 21:47:34 +0300 Subject: test_tool_stdout_encoding: run the programs with -X utf8=0 Python 3.15 turns UTF-8 mode on by default, even under -I, so there a redirected stdout is UTF-8 and the subprocess cases pass with or without the guard. -X utf8=0 keeps the code page they are about (review of #2399 by nonverifiedperson). On 3.12 the flag changes nothing: 4 OK with the guard, 2 failures with viewer/serve.py's taken out. Co-Authored-By: Claude Mythos 5.2 Claude-Session: https://claude.ai/code/session_016ABh36DZ2sZNq3ChN6EZJs --- tests/test_tool_stdout_encoding.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'tests/test_tool_stdout_encoding.py') diff --git a/tests/test_tool_stdout_encoding.py b/tests/test_tool_stdout_encoding.py index 65427b79e..d5333a7fb 100644 --- a/tests/test_tool_stdout_encoding.py +++ b/tests/test_tool_stdout_encoding.py @@ -26,6 +26,9 @@ NOT_YET_GUARDED = { "scripts/run_wine_tests.py", # open Wine runner pull requests change this file } MARK = "" +# Python 3.15 turns UTF-8 mode on by default, even under -I, and then a redirected stdout cannot fail this way. +# -X utf8=0 keeps the code page these tests are about, so they still catch a missing guard there. +PYTHON = [sys.executable, "-I", "-X", "utf8=0"] class EveryToolGuardsStdout(unittest.TestCase): @@ -61,7 +64,7 @@ class MeasuredCrashes(unittest.TestCase): for tool, with_out in self.CASES: with self.subTest(tool=tool): argv = [src] + (["--out", out] if with_out else []) - r = subprocess.run([sys.executable, "-I", os.path.join(TOOLS, tool)] + argv, + r = subprocess.run(PYTHON + [os.path.join(TOOLS, tool)] + argv, capture_output=True, cwd=ROOT, timeout=300) err = r.stderr.decode("utf-8", "replace") self.assertNotIn("UnicodeEncodeError", err) @@ -75,8 +78,9 @@ class ScriptsAndViewer(unittest.TestCase): disasm = os.path.join(tmp, "disasm-" + MARK) os.makedirs(disasm) report = os.path.join(tmp, "rep-" + MARK + ".json") - r = subprocess.run([sys.executable, "-I", os.path.join(ROOT, "scripts", "audit_shader4_regs.py"), - disasm, "--json", report], capture_output=True, cwd=ROOT, timeout=300) + audit = os.path.join(ROOT, "scripts", "audit_shader4_regs.py") + r = subprocess.run(PYTHON + [audit, disasm, "--json", report], + capture_output=True, cwd=ROOT, timeout=300) err = r.stderr.decode("utf-8", "replace") self.assertNotIn("Traceback", err) self.assertEqual(r.returncode, 0, err) @@ -87,8 +91,8 @@ class ScriptsAndViewer(unittest.TestCase): with tempfile.TemporaryDirectory() as tmp: world = os.path.join(tmp, "world-" + MARK) os.makedirs(world) - proc = subprocess.Popen([sys.executable, "-I", os.path.join(ROOT, "viewer", "serve.py"), - "--world", world, "--port", "0"], + serve = os.path.join(ROOT, "viewer", "serve.py") + proc = subprocess.Popen(PYTHON + [serve, "--world", world, "--port", "0"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=ROOT) try: line = proc.stdout.readline() # the viewer prints this line once it is listening -- cgit v1.2.3