]> granicus.if.org Git - python/commitdiff
Issue #10197 Tweak docs for subprocess.getstatusoutput and align the documentation...
authorTim Golden <mail@timgolden.me.uk>
Tue, 5 Nov 2013 12:57:25 +0000 (12:57 +0000)
committerTim Golden <mail@timgolden.me.uk>
Tue, 5 Nov 2013 12:57:25 +0000 (12:57 +0000)
Doc/library/subprocess.rst
Lib/subprocess.py

index 96a0033e75baf0e5423e27b2dacaa36b1ea87a7d..2e88319458415c20a4d7858c4be2954da7e31bf6 100644 (file)
@@ -1058,9 +1058,9 @@ handling consistency are valid for these functions.
 
    Return ``(status, output)`` of executing *cmd* in a shell.
 
-   Execute the string *cmd* in a shell with :class:`Popen` and return a 2-tuple
-   ``(status, output)`` via :func:`Popen.communicate`. Universal newlines mode
-   is used; see the notes on :ref:`frequently-used-arguments` for more details.
+   Execute the string *cmd* in a shell with :meth:`Popen.check_output` and
+   return a 2-tuple ``(status, output)``. Universal newlines mode is used;
+   see the notes on :ref:`frequently-used-arguments` for more details.
 
    A trailing newline is stripped from the output.
    The exit status for the command can be interpreted
index 1bfd136ec4b2b15c334e356650fa1e4f5c5fd6f3..5b2811f9290c0a7fae469b1ce489c633697093ef 100644 (file)
@@ -145,11 +145,13 @@ check_call(*popenargs, **kwargs):
 getstatusoutput(cmd):
     Return (status, output) of executing cmd in a shell.
 
-    Execute the string 'cmd' in a shell with os.popen() and return a 2-tuple
-    (status, output).  cmd is actually run as '{ cmd ; } 2>&1', so that the
-    returned output will contain output or error messages. A trailing newline
-    is stripped from the output. The exit status for the command can be
-    interpreted according to the rules for the C function wait().  Example:
+    Execute the string 'cmd' in a shell with 'check_output' and
+    return a 2-tuple (status, output). Universal newlines mode is used,
+    meaning that the result with be decoded to a string.
+
+    A trailing newline is stripped from the output.
+    The exit status for the command can be interpreted
+    according to the rules for the function 'wait'.  Example:
 
     >>> subprocess.getstatusoutput('ls /bin/ls')
     (0, '/bin/ls')
@@ -684,13 +686,15 @@ def list2cmdline(seq):
 # NB This only works (and is only relevant) for POSIX.
 
 def getstatusoutput(cmd):
-    """Return (status, output) of executing cmd in a shell.
+    """    Return (status, output) of executing cmd in a shell.
+
+    Execute the string 'cmd' in a shell with 'check_output' and
+    return a 2-tuple (status, output). Universal newlines mode is used,
+    meaning that the result with be decoded to a string.
 
-    Execute the string 'cmd' in a shell with os.popen() and return a 2-tuple
-    (status, output).  cmd is actually run as '{ cmd ; } 2>&1', so that the
-    returned output will contain output or error messages.  A trailing newline
-    is stripped from the output.  The exit status for the command can be
-    interpreted according to the rules for the C function wait().  Example:
+    A trailing newline is stripped from the output.
+    The exit status for the command can be interpreted
+    according to the rules for the function 'wait'. Example:
 
     >>> import subprocess
     >>> subprocess.getstatusoutput('ls /bin/ls')