classification
Title: Document & unittest the subprocess.getstatusoutput() status value
Type: behavior Stage: resolved
Components: Documentation Versions: Python 3.7, Python 3.6, Python 3.3, Python 3.4, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder: subprocess.getstatusoutput changed behavior in 3.4 (maybe 3.3.4?)
View: 22635
Assigned To: gregory.p.smith Nosy List: Arfrever, gregory.p.smith
Priority: normal Keywords:

Created on 2015-02-24 08:56 by gregory.p.smith, last changed 2017-09-14 22:01 by gregory.p.smith. This issue is now closed.

Messages (3)
msg236482 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2015-02-24 08:56
The changes from http://bugs.python.org/issue10197 caused subprocess.getstatusoutput() to start returning a subprocess returncode style status for the child process instead of a POSIX style status.

before that bug's changes:

>>> getstatusoutput("exit 1")[0]
256
>>> getstatusoutput("kill -TERM $$")[0]
15

after that bug's changes:

>>> getstatusoutput("exit 1")[0]
1
>>> getstatusoutput("kill -TERM $$")[0]
-15

This behavior was entirely untested so it was missed when fixing issue10197.

Given the new behavior has shipped in a stable Python release starting with (I believe) 3.3.4 and all 3.4 releases I do not think it should be changed.

But we should document it with proper versionchanged notices.
msg236532 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2015-02-24 19:30
Workaround: To determine the behavior of the interpreter your POSIX program is running under rather than a hard coded patch level version check, write appropriate conditional code to perform a test such as:

_returns_new_status = subprocess.getstatusoutput('kill $$')[0] < 0
msg302219 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2017-09-14 22:01
documentation updates as part of issue22635.
History
Date User Action Args
2017-09-14 22:01:32gregory.p.smithsetstatus: open -> closed

type: behavior
superseder: subprocess.getstatusoutput changed behavior in 3.4 (maybe 3.3.4?)
assignee: gregory.p.smith
components: + Documentation
versions: + Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7
messages: + msg302219
resolution: fixed
stage: resolved
2015-02-25 10:04:46Arfreversetnosy: + Arfrever
2015-02-24 19:30:51gregory.p.smithsetmessages: + msg236532
2015-02-24 08:56:18gregory.p.smithcreate