diff --git a/Lib/distutils/_msvccompiler.py b/Lib/distutils/_msvccompiler.py --- a/Lib/distutils/_msvccompiler.py +++ b/Lib/distutils/_msvccompiler.py @@ -90,6 +90,7 @@ def _get_vc_env(plat_spec): shell=True, stderr=subprocess.STDOUT, universal_newlines=True, + errors="replace", ) except subprocess.CalledProcessError as exc: log.error(exc.output) diff --git a/Lib/subprocess.py b/Lib/subprocess.py --- a/Lib/subprocess.py +++ b/Lib/subprocess.py @@ -30,7 +30,8 @@ class Popen(args, bufsize=-1, executable=None, preexec_fn=None, close_fds=True, shell=False, cwd=None, env=None, universal_newlines=False, startupinfo=None, creationflags=0, - restore_signals=True, start_new_session=False, pass_fds=()): + restore_signals=True, start_new_session=False, + pass_fds=(), errors=None): Arguments are: @@ -73,6 +74,10 @@ parent. Additionally, stderr can be STDOUT, which indicates that the stderr data from the applications should be captured into the same file handle as for stdout. +errors will be passed to the underlying file descriptors for all of +stdin, stdout and stderr. By default, it is None, which is the same as +'strict'. + On POSIX, if preexec_fn is set to a callable object, this object will be called in the child process just before the child is executed. The use of preexec_fn is not thread safe, using it in the presence of threads @@ -848,7 +853,7 @@ class Popen(object): shell=False, cwd=None, env=None, universal_newlines=False, startupinfo=None, creationflags=0, restore_signals=True, start_new_session=False, - pass_fds=()): + pass_fds=(), errors=None): """Create new Popen instance.""" _cleanup() # Held while anything is calling waitpid before returncode has been @@ -934,16 +939,16 @@ class Popen(object): errread = msvcrt.open_osfhandle(errread.Detach(), 0) if p2cwrite != -1: - self.stdin = io.open(p2cwrite, 'wb', bufsize) + self.stdin = io.open(p2cwrite, 'wb', bufsize, errors=errors) if universal_newlines: self.stdin = io.TextIOWrapper(self.stdin, write_through=True, line_buffering=(bufsize == 1)) if c2pread != -1: - self.stdout = io.open(c2pread, 'rb', bufsize) + self.stdout = io.open(c2pread, 'rb', bufsize, errors=errors) if universal_newlines: self.stdout = io.TextIOWrapper(self.stdout) if errread != -1: - self.stderr = io.open(errread, 'rb', bufsize) + self.stderr = io.open(errread, 'rb', bufsize, errors=errors) if universal_newlines: self.stderr = io.TextIOWrapper(self.stderr)