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="surrogateescape", ) 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: @@ -107,6 +108,10 @@ process. If universal_newlines is False, the file objects stdin, stdout and stderr are opened as binary files, and no line ending conversion is done. +errors will be passed to the underlying file descriptors for all of +stdin, stdout and stderr, if universal_newlines is True. By default, +it is None, which is the same as 'strict'. + If universal_newlines is True, the file objects stdout and stderr are opened as a text file, but lines may be terminated by any of '\n', the Unix end-of-line convention, '\r', the old Macintosh convention or @@ -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 @@ -937,15 +942,16 @@ class Popen(object): self.stdin = io.open(p2cwrite, 'wb', bufsize) if universal_newlines: self.stdin = io.TextIOWrapper(self.stdin, write_through=True, - line_buffering=(bufsize == 1)) + line_buffering=(bufsize == 1), + errors=errors) if c2pread != -1: self.stdout = io.open(c2pread, 'rb', bufsize) if universal_newlines: - self.stdout = io.TextIOWrapper(self.stdout) + self.stdout = io.TextIOWrapper(self.stdout, errors=errors) if errread != -1: self.stderr = io.open(errread, 'rb', bufsize) if universal_newlines: - self.stderr = io.TextIOWrapper(self.stderr) + self.stderr = io.TextIOWrapper(self.stderr, errors=errors) self._closed_child_pipe_fds = False try: