Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitec1f6f5

Browse files
authored
gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,the ANSI code page is now used as the encoding for the stdouttemporary file, rather than using UTF-8 which can lead to decodingerrors.
1 parent82ccbf6 commitec1f6f5

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

‎Lib/test/libregrtest/runtest_mp.py‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
fromtest.libregrtest.setupimportsetup_tests
2323
fromtest.libregrtest.utilsimportformat_duration,print_warning
2424

25+
ifsys.platform=='win32':
26+
importlocale
27+
2528

2629
# Display the running tests if nothing happened last N seconds
2730
PROGRESS_UPDATE=30.0# seconds
@@ -267,11 +270,16 @@ def _run_process(self, test_name: str, tmp_dir: str, stdout_fh: TextIO) -> int:
267270
self.current_test_name=None
268271

269272
def_runtest(self,test_name:str)->MultiprocessResult:
273+
ifsys.platform=='win32':
274+
# gh-95027: When stdout is not a TTY, Python uses the ANSI code
275+
# page for the sys.stdout encoding. If the main process runs in a
276+
# terminal, sys.stdout uses WindowsConsoleIO with UTF-8 encoding.
277+
encoding=locale.getencoding()
278+
else:
279+
encoding=sys.stdout.encoding
270280
# gh-94026: Write stdout+stderr to a tempfile as workaround for
271281
# non-blocking pipes on Emscripten with NodeJS.
272-
withtempfile.TemporaryFile(
273-
'w+',encoding=sys.stdout.encoding
274-
)asstdout_fh:
282+
withtempfile.TemporaryFile('w+',encoding=encoding)asstdout_fh:
275283
# gh-93353: Check for leaked temporary files in the parent process,
276284
# since the deletion of temporary files can happen late during
277285
# Python finalization: too late for libregrtest.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
On Windows, when the Python test suite is run with the ``-jN`` option, the
2+
ANSI code page is now used as the encoding for the stdout temporary file,
3+
rather than using UTF-8 which can lead to decoding errors. Patch by Victor
4+
Stinner.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp