]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-133711: Fix test_regrtest for PYTHONUTF8=1 (#134839)
authorVictor Stinner <vstinner@python.org>
Wed, 28 May 2025 15:19:50 +0000 (17:19 +0200)
committerGitHub <noreply@github.com>
Wed, 28 May 2025 15:19:50 +0000 (17:19 +0200)
Use "backslashreplace" error handler to decode stdout and stderr.
Example:

    vstinner@WIN C:\victor\python\main\build\test_python_worker_8360\x91>
    "C:\victor\python\main\PCbuild\amd64\python_d.exe"  -m test
    --fast-ci --slow-ci --testdir
    C:\Users\vstinner\AppData\Local\Temp\tmp0t59e8da
    test_regrtest_noop1 test_regrtest_noop2 test_regrtest_noop3
    test_regrtest_noop4

Notice the "\x91" byte at the end of the first line: it's the
non-ASCII U+00E6 character encoded to the OEM cp437 code page.

Lib/test/test_regrtest.py

index 7e317d5ab943ff5ab62ea3538ed9168292aef78c..8f4fc09442e083b67344e44eabc01178391c2ba0 100644 (file)
@@ -874,7 +874,10 @@ class ProgramsTestCase(BaseTestCase):
         self.run_tests(args)
 
     def run_batch(self, *args):
-        proc = self.run_command(args)
+        proc = self.run_command(args,
+                                # gh-133711: cmd.exe uses the OEM code page
+                                # to display the non-ASCII current directory
+                                errors="backslashreplace")
         self.check_output(proc.stdout)
 
     @unittest.skipUnless(sysconfig.is_python_build(),