Skip to content

Commit dee54f6

Browse files
miss-islingtontiran
authored andcommitted
[3.6] bpo-22635: subprocess.getstatusoutput doc update. (pythonGH-3398) (python#3411)
The `subprocess.getstatusoutput` API was inadvertently changed in Python 3.3.4. Document the change, it is too late to undo the API change now as it has shipped in many stable releases. (cherry picked from commit 738b7d9)
1 parent aa1afc7 commit dee54f6

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

‎Doc/library/subprocess.rst‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,27 +1166,32 @@ handling consistency are valid for these functions.
11661166

11671167
.. function:: getstatusoutput(cmd)
11681168

1169-
Return ``(status, output)`` of executing *cmd* in a shell.
1169+
Return ``(exitcode, output)`` of executing *cmd* in a shell.
11701170

11711171
Execute the string *cmd* in a shell with :meth:`Popen.check_output` and
1172-
return a 2-tuple ``(status, output)``. The locale encoding is used;
1172+
return a 2-tuple ``(exitcode, output)``. The locale encoding is used;
11731173
see the notes on :ref:`frequently-used-arguments` for more details.
11741174

11751175
A trailing newline is stripped from the output.
1176-
The exit status for the command can be interpreted
1177-
according to the rules for the C function :c:func:`wait`. Example::
1176+
The exit code for the command can be interpreted as the return code
1177+
of subprocess. Example::
11781178

11791179
>>> subprocess.getstatusoutput('ls /bin/ls')
11801180
(0, '/bin/ls')
11811181
>>> subprocess.getstatusoutput('cat /bin/junk')
1182-
(256, 'cat: /bin/junk: No such file or directory')
1182+
(1, 'cat: /bin/junk: No such file or directory')
11831183
>>> subprocess.getstatusoutput('/bin/junk')
1184-
(256, 'sh: /bin/junk: not found')
1184+
(127, 'sh: /bin/junk: not found')
1185+
>>> subprocess.getstatusoutput('/bin/kill $$')
1186+
(-15, '')
11851187

11861188
Availability: POSIX & Windows
11871189

11881190
.. versionchanged:: 3.3.4
1189-
Windows support added
1191+
Windows support was added.
1192+
1193+
The function now returns (exitcode, output) instead of (status, output)
1194+
as it did in Python 3.3.3 and earlier. See :func:`WEXITSTATUS`.
11901195

11911196

11921197
.. function:: getoutput(cmd)

0 commit comments

Comments
 (0)