From b054ebc8f304771298001f67228f6070917a3422 Mon Sep 17 00:00:00 2001 From: "szager@chromium.org" Date: Tue, 30 Apr 2013 19:10:52 +0000 Subject: [PATCH] Don't discard stderr. R=maruel@chromium.org NOTRY=true Review URL: https://codereview.chromium.org/14643009 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@197419 0039d316-1c4b-4281-b951-d872f2087c98 --- subprocess2.py | 1 - tests/subprocess2_test.py | 8 ++++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/subprocess2.py b/subprocess2.py index 364aace88..1f9c6c99e 100644 --- a/subprocess2.py +++ b/subprocess2.py @@ -355,7 +355,6 @@ class Popen(subprocess.Popen): self._tee_threads(input) if stdout is not None: stdout = ''.join(stdout) - stderr = None if stderr is not None: stderr = ''.join(stderr) return (stdout, stderr) diff --git a/tests/subprocess2_test.py b/tests/subprocess2_test.py index 917e106af..9d7df5bed 100755 --- a/tests/subprocess2_test.py +++ b/tests/subprocess2_test.py @@ -326,6 +326,14 @@ class RegressionTest(BaseTestCase): self._check_res(res, None, None, 0) self._run_test(fn) + def test_stderr(self): + cmd = ['expr', '1', '/', '0'] + p1 = subprocess.Popen(cmd, stderr=subprocess.PIPE) + p2 = subprocess2.Popen(cmd, stderr=subprocess.PIPE) + r1 = p1.communicate() + r2 = p2.communicate(timeout=100) + self.assertEquals(r1, r2) + class S2Test(BaseTestCase): # Tests that can only run in subprocess2, e.g. new functionalities.