Commit c15fe57f authored by tandrii@chromium.org's avatar tandrii@chromium.org

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
parent 2674ae08
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment