[Python-ideas] Subprocess: Add an encoding argument
Paul Moore
p.f.moore at gmail.com
Fri Aug 29 09:51:00 CEST 2014
At the moment, subprocess offers two options for handlingthe standard
IO streams of the child. By default, the streams are binary, or you
can set universal_newlines to get text-mode streams with universal
newline handling enabled.
With universal_newlines, the encoding of the streams is the default
value for the environment (whatever locale.getpreferredencoding()
returns). However, there can be cases where you want finer control
over the encoding to use (for example, if you run Python in a
subprocess and set PYTHONIOENCODING).
I propose adding an "encoding" parameter to subprocess.Popen (and the
various wrapper routines) to allow specifying the actual encoding to
use.
Obviously, you can simply wrap the binary streams yourself - the main
use for this facility would be in the higher level functions like
check_output and communicate.
Does this seem like a reasonable suggestion?
Paul
More information about the Python-ideas
mailing list