Make check_output of subprocess2 compatible with Python's subprocess.
According to Python's doc (
https://docs.python.org/2/library/subprocess.html#subprocess.check_output
):
if check_output raises exception CalledProcessError, the exception object
should contain stdout data as `output` attribute. Before this commit,
subprocess2.CalledProcessError had `output` always None, and used `stdout`
instead. This commit fixes this problem storing the same data in both `stdout`
and `output`.
BUG=NONE
Review URL: https://codereview.chromium.org/582933002
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@292036 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/subprocess2.py b/subprocess2.py
index 9f547a6..6e138a5 100644
--- a/subprocess2.py
+++ b/subprocess2.py
@@ -34,8 +34,8 @@
class CalledProcessError(subprocess.CalledProcessError):
"""Augment the standard exception with more data."""
def __init__(self, returncode, cmd, cwd, stdout, stderr):
- super(CalledProcessError, self).__init__(returncode, cmd)
- self.stdout = stdout
+ super(CalledProcessError, self).__init__(returncode, cmd, output=stdout)
+ self.stdout = self.output # for backward compatibility.
self.stderr = stderr
self.cwd = cwd