Skip to content

Commit fb4c28c

Browse files
miss-islingtongpshead
authored andcommitted
[3.6] bpo-22635: Update the getstatusoutput docstring. (GH-3435) (#3439)
To match the documentation updates already made. Also renames the local variable used within to match what it actually holds. (cherry picked from commit 2eb0cb4)
1 parent 27ce5a1 commit fb4c28c

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
@@ -493,7 +493,7 @@ def list2cmdline(seq):
493493
#
494494

495495
def getstatusoutput(cmd):
496-
""" Return (status, output) of executing cmd in a shell.
496+
"""Return (exitcode, output) of executing cmd in a shell.
497497
498498
Execute the string 'cmd' in a shell with 'check_output' and
499499
return a 2-tuple (status, output). The locale encoding is used
@@ -507,19 +507,21 @@ def getstatusoutput(cmd):
507507
>>> subprocess.getstatusoutput('ls /bin/ls')
508508
(0, '/bin/ls')
509509
>>> subprocess.getstatusoutput('cat /bin/junk')
510-
(256, 'cat: /bin/junk: No such file or directory')
510+
(1, 'cat: /bin/junk: No such file or directory')
511511
>>> subprocess.getstatusoutput('/bin/junk')
512-
(256, 'sh: /bin/junk: not found')
512+
(127, 'sh: /bin/junk: not found')
513+
>>> subprocess.getstatusoutput('/bin/kill $$')
514+
(-15, '')
513515
"""
514516
try:
515517
data = check_output(cmd, shell=True, universal_newlines=True, stderr=STDOUT)
516-
status = 0
518+
exitcode = 0
517519
except CalledProcessError as ex:
518520
data = ex.output
519-
status = ex.returncode
521+
exitcode = ex.returncode
520522
if data[-1:] == '\n':
521523
data = data[:-1]
522-
return status, data
524+
return exitcode, data
523525

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

0 commit comments

Comments
 (0)