[issue27179] subprocess uses wrong encoding on Windows

Steve Dower report at bugs.python.org
Thu Jun 2 22:31:39 EDT 2016


Steve Dower added the comment:

> There is right encoding, it's encoding that's actually used.

This is true, but it puts the decision entirely in the hands of the developer(s) of the two processes involved.

All IPC on Windows uses bytes, and encodings _always_ need to be negotiated by the processes involved. You can't reliably assume or infer anything. The closest you get is to assume that both processes are using the same MSVCRT version and have not changed the defaults (except Python changes the defaults, from text to binary, so that assumption is easily broken).

Using "cmd /u" is one way to negotiate with that process for the shell=True case, but all others basically just require an explicit encoding parameter so that it can be specified. IMHO, if we make Python default to UTF-8 and subprocess use utf_8:errors (mojibake is not acceptable by default) and "cmd /u", we cover enough common cases to minimise the need to explicitly specify. (A close second best is to default to the console CP if available and default locale otherwise.)

----------

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


More information about the Python-bugs-list mailing list