Skip to content

Commit 2eb0cb4

Browse files
authored
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.
1 parent 888bbdc commit 2eb0cb4

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

Lib/subprocess.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
getoutput(...): Runs a command in the shell, waits for it to complete,
3939
then returns the output
4040
getstatusoutput(...): Runs a command in the shell, waits for it to complete,
41-
then returns a (status, output) tuple
41+
then returns a (exitcode, output) tuple
4242
"""
4343

4444
import sys
@@ -492,7 +492,7 @@ def list2cmdline(seq):
492492
#
493493

494494
def getstatusoutput(cmd):
495-
""" Return (status, output) of executing cmd in a shell.
495+
"""Return (exitcode, output) of executing cmd in a shell.
496496
497497
Execute the string 'cmd' in a shell with 'check_output' and
498498
return a 2-tuple (status, output). The locale encoding is used
@@ -506,19 +506,21 @@ def getstatusoutput(cmd):
506506
>>> subprocess.getstatusoutput('ls /bin/ls')
507507
(0, '/bin/ls')
508508
>>> subprocess.getstatusoutput('cat /bin/junk')
509-
(256, 'cat: /bin/junk: No such file or directory')
509+
(1, 'cat: /bin/junk: No such file or directory')
510510
>>> subprocess.getstatusoutput('/bin/junk')
511-
(256, 'sh: /bin/junk: not found')
511+
(127, 'sh: /bin/junk: not found')
512+
>>> subprocess.getstatusoutput('/bin/kill $$')
513+
(-15, '')
512514
"""
513515
try:
514516
data = check_output(cmd, shell=True, universal_newlines=True, stderr=STDOUT)
515-
status = 0
517+
exitcode = 0
516518
except CalledProcessError as ex:
517519
data = ex.output
518-
status = ex.returncode
520+
exitcode = ex.returncode
519521
if data[-1:] == '\n':
520522
data = data[:-1]
521-
return status, data
523+
return exitcode, data
522524

523525
def getoutput(cmd):
524526
"""Return output (stdout or stderr) of executing cmd in a shell.

0 commit comments

Comments
 (0)