[Python-checkins] cpython: Issue #10197 Tweak docs for subprocess.getstatusoutput and align the
tim.golden
python-checkins at python.org
Tue Nov 5 13:58:41 CET 2013
http://hg.python.org/cpython/rev/0aa2aedc6a21
changeset: 86941:0aa2aedc6a21
user: Tim Golden <mail at timgolden.me.uk>
date: Tue Nov 05 12:57:25 2013 +0000
summary:
Issue #10197 Tweak docs for subprocess.getstatusoutput and align the documentation, the module docstring, and the function docstring.
files:
Doc/library/subprocess.rst | 6 +++---
Lib/subprocess.py | 26 +++++++++++++++-----------
2 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/Doc/library/subprocess.rst b/Doc/library/subprocess.rst
--- a/Doc/library/subprocess.rst
+++ b/Doc/library/subprocess.rst
@@ -1058,9 +1058,9 @@
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
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -145,11 +145,13 @@
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 @@
# 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 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:
>>> import subprocess
>>> subprocess.getstatusoutput('ls /bin/ls')
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list