Skip to content

Commit

Permalink
Revert "pythongh-95027: Fix regrtest stdout encoding on Windows (pyth…
Browse files Browse the repository at this point in the history
…onGH-98492)"

This reverts commit b2aa28e.
  • Loading branch information
vstinner committed Sep 2, 2023
1 parent 39bf879 commit 9a03f9c
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions Lib/test/libregrtest/runtest_mp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 9a03f9c

Please sign in to comment.