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

Skip to content

Commit 738b7d9

Browse files
authored
bpo-22635: subprocess.getstatusoutput doc update. (#3398)
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.
1 parent d01db1c commit 738b7d9

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
@@ -1165,27 +1165,32 @@ handling consistency are valid for these functions.
11651165

11661166
.. function:: getstatusoutput(cmd)
11671167

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

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

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

11781178
>>> subprocess.getstatusoutput('ls /bin/ls')
11791179
(0, '/bin/ls')
11801180
>>> subprocess.getstatusoutput('cat /bin/junk')
1181-
(256, 'cat: /bin/junk: No such file or directory')
1181+
(1, 'cat: /bin/junk: No such file or directory')
11821182
>>> subprocess.getstatusoutput('/bin/junk')
1183-
(256, 'sh: /bin/junk: not found')
1183+
(127, 'sh: /bin/junk: not found')
1184+
>>> subprocess.getstatusoutput('/bin/kill $$')
1185+
(-15, '')
11841186

11851187
Availability: POSIX & Windows
11861188

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

11901195

11911196
.. function:: getoutput(cmd)

0 commit comments

Comments
 (0)