Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
Description
PYTHONLEGACYWINDOWSSTDIO
will let Windows use old console IO forstdin
andstdout
, andsys.stdin.encoding
will becomecp
instead ofutf-8
.
cpython/Lib/test/test_cmd_line.py
Lines 974 to 978 in0af61fe
deftest_python_legacy_windows_stdio(self): | |
code="import sys; print(sys.stdin.encoding, sys.stdout.encoding)" | |
expected='cp' | |
rc,out,err=assert_python_ok('-c',code,PYTHONLEGACYWINDOWSSTDIO='1') | |
self.assertIn(expected.encode(),out) |
In this test, it setsPYTHONLEGACYWINDOWSSTDIO
to1
and creates a new Python process to check ifsys.stdin.encoding
iscp
. However, the new process is created bysubprocess.Popen
withstdin=PIPE, stdout=PIPE
, thus thesys.stdin
andsys.stdout
will not be console IO, so their encoding is always the current console code page (cp
) whetherPYTHONLEGACYWINDOWSSTDIO
is set or not. So actually nothing has been tested.
Another issue with this test is that it expects the encoding to becp
, but on some non-English locale Windows environments, for example, Simplified Chinese locale, it will begbk
, and the test will fail.
A fix is on the way.