|
22 | 22 | from test.libregrtest.setup import setup_tests
|
23 | 23 | from test.libregrtest.utils import format_duration, print_warning
|
24 | 24 |
|
| 25 | +if sys.platform == 'win32': |
| 26 | + import locale |
| 27 | + |
25 | 28 |
|
26 | 29 | # Display the running tests if nothing happened last N seconds
|
27 | 30 | PROGRESS_UPDATE = 30.0 # seconds
|
@@ -267,11 +270,16 @@ def _run_process(self, test_name: str, tmp_dir: str, stdout_fh: TextIO) -> int:
|
267 | 270 | self.current_test_name = None
|
268 | 271 |
|
269 | 272 | def _runtest(self, test_name: str) -> MultiprocessResult:
|
| 273 | + if sys.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 |
270 | 280 | # gh-94026: Write stdout+stderr to a tempfile as workaround for
|
271 | 281 | # non-blocking pipes on Emscripten with NodeJS.
|
272 |
| - with tempfile.TemporaryFile( |
273 |
| - 'w+', encoding=sys.stdout.encoding |
274 |
| - ) as stdout_fh: |
| 282 | + with tempfile.TemporaryFile('w+', encoding=encoding) as stdout_fh: |
275 | 283 | # gh-93353: Check for leaked temporary files in the parent process,
|
276 | 284 | # since the deletion of temporary files can happen late during
|
277 | 285 | # Python finalization: too late for libregrtest.
|
|
0 commit comments