subprocess2: Fix CalledProcessError str() method on Python 3.
stdout and stderr are bytes in Python 3 and must be decoded before
printing the exception.
Bug: 1060409
Change-Id: Ib855f6104919734b7505aa5e978ebe394a1e9db6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2097595
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
diff --git a/subprocess2.py b/subprocess2.py
index 9ae485d..c40d111 100644
--- a/subprocess2.py
+++ b/subprocess2.py
@@ -48,7 +48,11 @@
' '.join(self.cmd), self.returncode)
if self.cwd:
out += ' in ' + self.cwd
- return '\n'.join(filter(None, (out, self.stdout, self.stderr)))
+ if self.stdout:
+ out += '\n' + self.stdout.decode('utf-8', 'ignore')
+ if self.stderr:
+ out += '\n' + self.stderr.decode('utf-8', 'ignore')
+ return out
class CygwinRebaseError(CalledProcessError):