From 4a982271a7000caf4d82e954dc2ebd21deb2b8fc Mon Sep 17 00:00:00 2001 From: "maruel@chromium.org" Date: Tue, 12 Apr 2011 20:49:37 +0000 Subject: [PATCH] Defaults stdin to VOID for capture and check_output() Since no output is user visible anyway, causing a hang with no clue about what to type in. R=dpranke@chromium.org BUG= TEST= Review URL: http://codereview.chromium.org/6823091 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@81302 0039d316-1c4b-4281-b951-d872f2087c98 --- subprocess2.py | 6 ++++++ tests/subprocess2_test.py | 1 + 2 files changed, 7 insertions(+) diff --git a/subprocess2.py b/subprocess2.py index b22d3e1ab..3cc79aeb8 100644 --- a/subprocess2.py +++ b/subprocess2.py @@ -259,7 +259,10 @@ def capture(args, **kwargs): - Discards returncode. - Discards stderr. By default sets stderr=STDOUT. + - Blocks stdin by default since no output will be visible. """ + if kwargs.get('stdin') is None: + kwargs['stdin'] = VOID if kwargs.get('stdout') is None: kwargs['stdout'] = PIPE if kwargs.get('stderr') is None: @@ -275,7 +278,10 @@ def check_output(args, **kwargs): - Discards stderr. By default sets stderr=STDOUT. - Throws if return code is not 0. - Works even prior to python 2.7. + - Blocks stdin by default since no output will be visible. """ + if kwargs.get('stdin') is None: + kwargs['stdin'] = VOID if kwargs.get('stdout') is None: kwargs['stdout'] = PIPE if kwargs.get('stderr') is None: diff --git a/tests/subprocess2_test.py b/tests/subprocess2_test.py index 448a82d34..552a93c49 100755 --- a/tests/subprocess2_test.py +++ b/tests/subprocess2_test.py @@ -125,6 +125,7 @@ class Subprocess2Test(unittest.TestCase): expected = { 'args': ['foo'], 'a':True, + 'stdin': subprocess2.VOID, 'stdout': subprocess2.PIPE, 'stderr': subprocess2.STDOUT, }