gh-133374: Fix test_python_legacy_windows_stdio in test_cmd_line#133375
gh-133374: Fix test_python_legacy_windows_stdio in test_cmd_line#133375aisk wants to merge 3 commits into
Conversation
zooba
left a comment
There was a problem hiding this comment.
I suspect there's a good chance it's not getting real console handles in CI systems either... maybe we should also print type(sys.stdout) (or possibly we have to dig into .buffer.raw)?
Co-authored-by: Steve Dower <steve.dower@microsoft.com>
Tested it on my own repo with: import sys
print(sys.stdin.encoding, sys.stdout.encoding)
print(sys.stdin.buffer.raw, sys.stdout.buffer.raw)And the result is: Instead of what I've got on my local machine: utf-8 utf-8
<_io._WindowsConsoleIO mode='rb' closefd=False> <_io._WindowsConsoleIO mode='wb' closefd=False>So I think there is no real consoles on GHA, and we can't run this case on it. I guess we can just add |
|
After reading #114565, I'm not sure whether However, I found that it is not enabled or run in CI because the If we intend to enable the |
|
Or we can just skip the test partway through ( |
serhiy-storchaka
left a comment
There was a problem hiding this comment.
This does not test the stderr encoding.
We should use other way to pass data from subprocess. For example, temporary file or shared file descriptor (if this is supported on Windows).
| out = p.stderr.read() | ||
| p.stderr.close() | ||
| p.wait() | ||
| self.assertNotIn(b'utf-8', out) |
There was a problem hiding this comment.
This might not be true. It's entirely possible to set the default encoding to UTF-8 in Windows itself, at which point the legacy stdio will also be UTF-8.
Checking the type of the stdin/stdout objects in the subprocess is probably the best way. The real purpose of this environment variable is to go back to using FileIO rather than _WindowsConsoleIO, and the encoding is only a side-effect of that.
And if we just make the child process assert, then we can check the exit code rather than reading the output.
test_python_legacy_windows_stdiointest_cmd_lineisn't actually working #133374