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

test_python_legacy_windows_stdio intest_cmd_line isn't actually working #133374

Closed
Labels
@aisk

Description

@aisk

PYTHONLEGACYWINDOWSSTDIO will let Windows use old console IO forstdin andstdout, andsys.stdin.encoding will becomecp instead ofutf-8.

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.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp