Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6079814

Browse files
committed
Issue #10197 Tweak docs for subprocess.getstatusoutput and align the documentation, the module docstring, and the function docstring.
1 parent be47cff commit 6079814

2 files changed

Lines changed: 18 additions & 14 deletions

File tree

Doc/library/subprocess.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,9 +1058,9 @@ handling consistency are valid for these functions.
10581058

10591059
Return ``(status, output)`` of executing *cmd* in a shell.
10601060

1061-
Execute the string *cmd* in a shell with :class:`Popen` and return a 2-tuple
1062-
``(status, output)`` via :func:`Popen.communicate`. Universal newlines mode
1063-
is used; see the notes on :ref:`frequently-used-arguments` for more details.
1061+
Execute the string *cmd* in a shell with :meth:`Popen.check_output` and
1062+
return a 2-tuple ``(status, output)``. Universal newlines mode is used;
1063+
see the notes on :ref:`frequently-used-arguments` for more details.
10641064

10651065
A trailing newline is stripped from the output.
10661066
The exit status for the command can be interpreted

Lib/subprocess.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,13 @@ class Popen(args, bufsize=-1, executable=None,
145145
getstatusoutput(cmd):
146146
Return (status, output) of executing cmd in a shell.
147147
148-
Execute the string 'cmd' in a shell with os.popen() and return a 2-tuple
149-
(status, output). cmd is actually run as '{ cmd ; } 2>&1', so that the
150-
returned output will contain output or error messages. A trailing newline
151-
is stripped from the output. The exit status for the command can be
152-
interpreted according to the rules for the C function wait(). Example:
148+
Execute the string 'cmd' in a shell with 'check_output' and
149+
return a 2-tuple (status, output). Universal newlines mode is used,
150+
meaning that the result with be decoded to a string.
151+
152+
A trailing newline is stripped from the output.
153+
The exit status for the command can be interpreted
154+
according to the rules for the function 'wait'. Example:
153155
154156
>>> subprocess.getstatusoutput('ls /bin/ls')
155157
(0, '/bin/ls')
@@ -684,13 +686,15 @@ def list2cmdline(seq):
684686
# NB This only works (and is only relevant) for POSIX.
685687

686688
def getstatusoutput(cmd):
687-
"""Return (status, output) of executing cmd in a shell.
689+
""" Return (status, output) of executing cmd in a shell.
690+
691+
Execute the string 'cmd' in a shell with 'check_output' and
692+
return a 2-tuple (status, output). Universal newlines mode is used,
693+
meaning that the result with be decoded to a string.
688694
689-
Execute the string 'cmd' in a shell with os.popen() and return a 2-tuple
690-
(status, output). cmd is actually run as '{ cmd ; } 2>&1', so that the
691-
returned output will contain output or error messages. A trailing newline
692-
is stripped from the output. The exit status for the command can be
693-
interpreted according to the rules for the C function wait(). Example:
695+
A trailing newline is stripped from the output.
696+
The exit status for the command can be interpreted
697+
according to the rules for the function 'wait'. Example:
694698
695699
>>> import subprocess
696700
>>> subprocess.getstatusoutput('ls /bin/ls')

0 commit comments

Comments
 (0)