[issue27179] subprocess uses wrong encoding on Windows

Martin Panter report at bugs.python.org
Wed Jun 1 22:38:26 EDT 2016


Martin Panter added the comment:

I don’t know much about the conventions for stdout etc encoding on Windows. But in general, the patch does not seem robust. Does it work if sys.stdout is a pipe or file (not a console)? I doubt it will work when sys.stdout has been replaced by e.g. StringIO, and sys.stdout.encoding is None. Maybe you could use sys.__stdout__. But then, what happens when you run Python without any stdout at all, say in a GUI like Idle?

On Linux, the patch may have no effect in common cases. But again, it will break if sys.stdout has been replaced, or is set to None.

Looking at _Py_device_encoding() in Python/fileutils.c, perhaps you need a Windows-specific interface to GetConsoleCP() and GetConsoleOutputCP() that subprocess can use.

----------
nosy: +martin.panter
stage:  -> patch review

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27179>
_______________________________________


More information about the Python-bugs-list mailing list