aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory P. Smith <greg@krypto.org>2017-09-07 16:11:02 -0700
committerGitHub <noreply@github.com>2017-09-07 16:11:02 -0700
commit2eb0cb4787d02d995a9bb6dc075983792c12835c (patch)
treed93b72b25ee68109200c9f42320657b3b659db49 /Lib/subprocess.py
parentbpo-27340: Use memoryview in SSLSocket.sendall() (#3384) (diff)
downloadcpython-2eb0cb4787d02d995a9bb6dc075983792c12835c.tar.gz
cpython-2eb0cb4787d02d995a9bb6dc075983792c12835c.tar.bz2
cpython-2eb0cb4787d02d995a9bb6dc075983792c12835c.zip
bpo-22635: Update the getstatusoutput docstring. (#3435)
To match the documentation updates already made. Also renames the local variable used within to match what it actually holds.
Diffstat (limited to 'Lib/subprocess.py')
-rw-r--r--Lib/subprocess.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index f61ff0c3946..6b90d40564f 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -38,7 +38,7 @@ check_output(...): Same as check_call() but returns the contents of
getoutput(...): Runs a command in the shell, waits for it to complete,
then returns the output
getstatusoutput(...): Runs a command in the shell, waits for it to complete,
- then returns a (status, output) tuple
+ then returns a (exitcode, output) tuple
"""
import sys
@@ -492,7 +492,7 @@ def list2cmdline(seq):
#
def getstatusoutput(cmd):
- """ Return (status, output) of executing cmd in a shell.
+ """Return (exitcode, output) of executing cmd in a shell.
Execute the string 'cmd' in a shell with 'check_output' and
return a 2-tuple (status, output). The locale encoding is used
@@ -506,19 +506,21 @@ def getstatusoutput(cmd):
>>> subprocess.getstatusoutput('ls /bin/ls')
(0, '/bin/ls')
>>> subprocess.getstatusoutput('cat /bin/junk')
- (256, 'cat: /bin/junk: No such file or directory')
+ (1, 'cat: /bin/junk: No such file or directory')
>>> subprocess.getstatusoutput('/bin/junk')
- (256, 'sh: /bin/junk: not found')
+ (127, 'sh: /bin/junk: not found')
+ >>> subprocess.getstatusoutput('/bin/kill $$')
+ (-15, '')
"""
try:
data = check_output(cmd, shell=True, universal_newlines=True, stderr=STDOUT)
- status = 0
+ exitcode = 0
except CalledProcessError as ex:
data = ex.output
- status = ex.returncode
+ exitcode = ex.returncode
if data[-1:] == '\n':
data = data[:-1]
- return status, data
+ return exitcode, data
def getoutput(cmd):
"""Return output (stdout or stderr) of executing cmd in a shell.