Repository navigation
Closed
Labels
OS-windowstestsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
The test test_embed fails on my Windows machine, using master branch (commit d0972c7).
python.bat -m test test_embed
Full output -
C:\Code\cpython>python.bat -m test test_embed
Running Debug|x64 interpreter...
0:00:00 Run tests sequentially
0:00:00 [1/1] test_embed
test test_embed failed -- Traceback (most recent call last):
File "C:\Code\cpython\Lib\test\test_embed.py", line 259, in test_forced_io_encoding
self.assertEqual(out.strip(), expected_output)
AssertionError: '--- [403 chars]din: utf-8:surrogateescape\nstdout: iso8859-1:[221 chars]lace' != '--- [403 chars]din: iso8859-1:surrogateescape\nstdout: iso885[229 chars]lace'
--- Use defaults ---
Expected encoding: default
Expected errors: default
stdin: utf-8:surrogateescape
stdout: utf-8:surrogateescape
stderr: utf-8:backslashreplace
--- Set errors only ---
Expected encoding: default
Expected errors: ignore
stdin: utf-8:ignore
stdout: utf-8:ignore
stderr: utf-8:backslashreplace
--- Set encoding only ---
Expected encoding: iso8859-1
Expected errors: default
- stdin: utf-8:surrogateescape
? ^^^ ^
+ stdin: iso8859-1:surrogateescape
? ^^^^^^^ ^
stdout: iso8859-1:surrogateescape
stderr: iso8859-1:backslashreplace
--- Set encoding and errors ---
Expected encoding: iso8859-1
Expected errors: replace
- stdin: utf-8:replace
+ stdin: iso8859-1:replace
stdout: iso8859-1:replace
stderr: iso8859-1:backslashreplace
test_embed failed (1 failure) in 30.7 sec
== Tests result: FAILURE ==
1 test failed:
test_embed
Total duration: 30.7 sec
Tests result: FAILURE
Your environment
- CPython versions tested on:
Running Debug|x64 interpreter...
Python 3.13.0a0
- Commit: d0972c7
- Operating system and architecture:
OS Name: Microsoft Windows 11 Pro
OS Version: 10.0.22621 N/A Build 22621
Linked PRs
Metadata
Metadata
Assignees
Labels
OS-windowstestsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Activity
eryksun commentedon Jul 12, 2023
The test doesn't override
sys.stdinin the child process. Thus when it's run normally,stdinis a console file. By default, the raw type of a console file isio._WindowsConsoleIO, which always uses UTF-8. The test expects to be able to override this, but being able to do this will either require forcingstdinto be a pipe or nul or it will require defining the environment variablePYTHONLEGACYWINDOWSSTDIO. The latter forces the use ofio.FileIOfor console files, instead ofio._WindowsConsoleIO.Eclips4 commentedon Aug 15, 2023
Bisected to #105154
cc @vstinner
pythongh-106659: Fix test_embed.test_forced_io_encoding() on Windows
vstinner commentedon Aug 16, 2023
Oh thanks for the bisect! I wrote PR #108010 to fix the regression. I'm able to reproduce the test failure on Windows when I run the test manually in a terminal.
vstinner commentedon Aug 16, 2023
The removed
Py_SetStandardStreamEncoding()function did set Py_LegacyWindowsStdioFlag:I missed that in my change. My PR fix it.
gh-106659: Fix test_embed.test_forced_io_encoding() on Windows (#108010)
vstinner commentedon Aug 16, 2023
It should now be fixed. Thanks for your bug report! Thanks @Eclips4 for your review on my PR.