[3.6] bpo-22635: Update the getstatusoutput docstring. (GH-3435) (#3439) · python/cpython@fb4c28c (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

`

`@@ -493,7 +493,7 @@ def list2cmdline(seq):

`

493

493

`#

`

494

494

``

495

495

`def getstatusoutput(cmd):

`

496

``

`-

""" Return (status, output) of executing cmd in a shell.

`

``

496

`+

"""Return (exitcode, output) of executing cmd in a shell.

`

497

497

``

498

498

` Execute the string 'cmd' in a shell with 'check_output' and

`

499

499

` return a 2-tuple (status, output). The locale encoding is used

`

`@@ -507,19 +507,21 @@ def getstatusoutput(cmd):

`

507

507

` >>> subprocess.getstatusoutput('ls /bin/ls')

`

508

508

` (0, '/bin/ls')

`

509

509

` >>> 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')

`

511

511

` >>> 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, '')

`

513

515

` """

`

514

516

`try:

`

515

517

`data = check_output(cmd, shell=True, universal_newlines=True, stderr=STDOUT)

`

516

``

`-

status = 0

`

``

518

`+

exitcode = 0

`

517

519

`except CalledProcessError as ex:

`

518

520

`data = ex.output

`

519

``

`-

status = ex.returncode

`

``

521

`+

exitcode = ex.returncode

`

520

522

`if data[-1:] == '\n':

`

521

523

`data = data[:-1]

`

522

``

`-

return status, data

`

``

524

`+

return exitcode, data

`

523

525

``

524

526

`def getoutput(cmd):

`

525

527

`"""Return output (stdout or stderr) of executing cmd in a shell.

`