[Python-checkins] [3.6] bpo-22635: Update the getstatusoutput docstring. (GH-3435) (#3439)

Gregory P. Smith webhook-mailer at python.org
Thu Sep 7 19:45:02 EDT 2017


https://github.com/python/cpython/commit/fb4c28c032e26b3cdbe67eae3769d45207ac3507
commit: fb4c28c032e26b3cdbe67eae3769d45207ac3507
branch: 3.6
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: Gregory P. Smith <greg at krypto.org>
date: 2017-09-07T16:44:58-07:00
summary:

[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 2eb0cb4787d02d995a9bb6dc075983792c12835c)

files:
M Lib/subprocess.py

diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index 575413d9870..290ae44f03d 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -38,7 +38,7 @@
 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
@@ -493,7 +493,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
@@ -507,19 +507,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.



More information about the Python-checkins mailing list