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

Commit90aa13a

Browse files
[3.14]gh-133374: fix test_python_legacy_windows_stdio (GH-134080) (GH-134314)
(cherry picked from commit652d693)Co-authored-by: Inada Naoki <songofacandy@gmail.com>
1 parent07a2033 commit90aa13a

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

‎Lib/test/test_cmd_line.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -972,10 +972,25 @@ def test_python_legacy_windows_fs_encoding(self):
972972

973973
@unittest.skipUnless(support.MS_WINDOWS,'Test only applicable on Windows')
974974
deftest_python_legacy_windows_stdio(self):
975-
code="import sys; print(sys.stdin.encoding, sys.stdout.encoding)"
976-
expected='cp'
977-
rc,out,err=assert_python_ok('-c',code,PYTHONLEGACYWINDOWSSTDIO='1')
978-
self.assertIn(expected.encode(),out)
975+
# Test that _WindowsConsoleIO is used when PYTHONLEGACYWINDOWSSTDIO
976+
# is not set.
977+
# We cannot use PIPE becase it prevents creating new console.
978+
# So we use exit code.
979+
code="import sys; sys.exit(type(sys.stdout.buffer.raw).__name__ != '_WindowsConsoleIO')"
980+
env=os.environ.copy()
981+
env["PYTHONLEGACYWINDOWSSTDIO"]=""
982+
p=subprocess.run([sys.executable,"-c",code],
983+
creationflags=subprocess.CREATE_NEW_CONSOLE,
984+
env=env)
985+
self.assertEqual(p.returncode,0)
986+
987+
# Then test that FIleIO is used when PYTHONLEGACYWINDOWSSTDIO is set.
988+
code="import sys; sys.exit(type(sys.stdout.buffer.raw).__name__ != 'FileIO')"
989+
env["PYTHONLEGACYWINDOWSSTDIO"]="1"
990+
p=subprocess.run([sys.executable,"-c",code],
991+
creationflags=subprocess.CREATE_NEW_CONSOLE,
992+
env=env)
993+
self.assertEqual(p.returncode,0)
979994

980995
@unittest.skipIf("-fsanitize"insysconfig.get_config_vars().get('PY_CFLAGS', ()),
981996
"PYTHONMALLOCSTATS doesn't work with ASAN")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp