Skip to content

Commit e3f1019

Browse files
committed
Fix test_python_legacy_windows_stdio in test_cmd_line
1 parent 1d9406e commit e3f1019

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Lib/test/test_cmd_line.py

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

973973
@unittest.skipUnless(support.MS_WINDOWS, 'Test only applicable on Windows')
974974
def test_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+
code = "import sys; print(sys.stdin.encoding, sys.stdout.encoding, file=sys.stderr)"
976+
env = os.environ.copy()
977+
env['PYTHONLEGACYWINDOWSSTDIO'] = '1'
978+
p = subprocess.Popen([sys.executable, '-c', code],
979+
stderr=subprocess.PIPE, env=env)
980+
out = p.stderr.read()
981+
p.stderr.close()
982+
p.wait()
983+
self.assertNotIn(b'utf-8', out)
979984

980985
@unittest.skipIf("-fsanitize" in sysconfig.get_config_vars().get('PY_CFLAGS', ()),
981986
"PYTHONMALLOCSTATS doesn't work with ASAN")

0 commit comments

Comments
 (0)