From c15fe57f12fa1de6e47f269bed883df82fd50038 Mon Sep 17 00:00:00 2001 From: "tandrii@chromium.org" Date: Fri, 19 Sep 2014 11:51:43 +0000 Subject: [PATCH] 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 --- subprocess2.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/subprocess2.py b/subprocess2.py index 9f547a63b..6e138a503 100644 --- a/subprocess2.py +++ b/subprocess2.py @@ -34,8 +34,8 @@ SUBPROCESS_CLEANUP_HACKED = False 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