bpo-22635: Update the getstatusoutput docstring. (#3435) · python/cpython@2eb0cb4 (original) (raw)
`@@ -38,7 +38,7 @@
`
38
38
`getoutput(...): Runs a command in the shell, waits for it to complete,
`
39
39
` then returns the output
`
40
40
`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
`
42
42
`"""
`
43
43
``
44
44
`import sys
`
`@@ -492,7 +492,7 @@ def list2cmdline(seq):
`
492
492
`#
`
493
493
``
494
494
`def getstatusoutput(cmd):
`
495
``
`-
""" Return (status, output) of executing cmd in a shell.
`
``
495
`+
"""Return (exitcode, output) of executing cmd in a shell.
`
496
496
``
497
497
` Execute the string 'cmd' in a shell with 'check_output' and
`
498
498
` return a 2-tuple (status, output). The locale encoding is used
`
`@@ -506,19 +506,21 @@ def getstatusoutput(cmd):
`
506
506
` >>> subprocess.getstatusoutput('ls /bin/ls')
`
507
507
` (0, '/bin/ls')
`
508
508
` >>> 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')
`
510
510
` >>> 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, '')
`
512
514
` """
`
513
515
`try:
`
514
516
`data = check_output(cmd, shell=True, universal_newlines=True, stderr=STDOUT)
`
515
``
`-
status = 0
`
``
517
`+
exitcode = 0
`
516
518
`except CalledProcessError as ex:
`
517
519
`data = ex.output
`
518
``
`-
status = ex.returncode
`
``
520
`+
exitcode = ex.returncode
`
519
521
`if data[-1:] == '\n':
`
520
522
`data = data[:-1]
`
521
``
`-
return status, data
`
``
523
`+
return exitcode, data
`
522
524
``
523
525
`def getoutput(cmd):
`
524
526
`"""Return output (stdout or stderr) of executing cmd in a shell.
`