From 9a03f9c5c4c977c7891e40dfdf97ff90cb25fe93 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Sat, 2 Sep 2023 18:51:05 +0200 Subject: [PATCH] Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)" This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f. --- Lib/test/libregrtest/runtest_mp.py | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/Lib/test/libregrtest/runtest_mp.py b/Lib/test/libregrtest/runtest_mp.py index c6a4dae2df86a9..13649ce10b3a41 100644 --- a/Lib/test/libregrtest/runtest_mp.py +++ b/Lib/test/libregrtest/runtest_mp.py @@ -21,9 +21,6 @@ from test.libregrtest.setup import setup_tests from test.libregrtest.utils import format_duration, print_warning -if sys.platform == 'win32': - import locale - # Display the running tests if nothing happened last N seconds PROGRESS_UPDATE = 30.0 # seconds @@ -262,16 +259,11 @@ def _run_process(self, test_name: str, stdout_fh: TextIO) -> int: self.current_test_name = None def _runtest(self, test_name: str) -> MultiprocessResult: - if sys.platform == 'win32': - # gh-95027: When stdout is not a TTY, Python uses the ANSI code - # page for the sys.stdout encoding. If the main process runs in a - # terminal, sys.stdout uses WindowsConsoleIO with UTF-8 encoding. - encoding = locale.getencoding() - else: - encoding = sys.stdout.encoding # gh-94026: Write stdout+stderr to a tempfile as workaround for # non-blocking pipes on Emscripten with NodeJS. - with tempfile.TemporaryFile('w+', encoding=encoding) as stdout_fh: + with tempfile.TemporaryFile( + 'w+', encoding=sys.stdout.encoding + ) as stdout_fh: # gh-93353: Check for leaked temporary files in the parent process, # since the deletion of temporary files can happen late during # Python finalization: too late for libregrtest.