This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: subprocess.py abuse of errno
Type: Stage:
Components: Library (Lib) Versions: Python 2.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: astrand Nosy List: anthonybaxter, astrand, hoffman, orenti
Priority: normal Keywords:

Created on 2005-06-20 06:56 by orenti, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
subprocess.patch astrand, 2006-07-10 22:53 Suggested fix for 2.5
Messages (8)
msg25579 - (view) Author: Oren Tirosh (orenti) Date: 2005-06-20 06:56
The CalledProcessError exception's .errno attribute is
set to a child process return code which is not an
errno. Any attempt to look up this number with
os.strerror() or errno.errorcode[] will result in
meaningless output. This can break existing code that
catches OSError and does not expect CalledProcessError.

Possible resolutions:

1. Don't make CalledProcessError a subclass of OSError
2. If CalledProcessError stays a subclass of OSError
.errno should be set to some specific meaningful value
(which one? add new value to errnomodule.c?) and use a
separate attribute for the child process return code.
msg25580 - (view) Author: Peter Åstrand (astrand) * (Python committer) Date: 2005-06-21 15:52
Logged In: YES 
user_id=344921

In hindsight, CalledProcessError should perhaps have been
designed some other way. But now when we have it, it's not
easy to change it. 

It all comes down to what is the documented behaviour and
not. As far as I understand, there's no requirement that the
errno number or an OSError should be possible to look up
with os.strerror(). I cannot find anything about this at
http://docs.python.org/lib/module-exceptions.html, at least.
All it says is "[errno is] assumed to be an error number". 

In my opinion, code should be prepared for "unknown" error
numbers. So currently, I'm not prepared to make any changes
to CalledProcessError. (If you disagree with me, post to
python-dev and see what others think.)
msg25581 - (view) Author: Peter Åstrand (astrand) * (Python committer) Date: 2005-06-21 20:13
Logged In: YES 
user_id=344921

I've changed my mind, since CalledProcessError is only in
the development version of Python. Perhaps it's acceptable
to change the API after all, then. Re-opening. 
msg25582 - (view) Author: Peter Åstrand (astrand) * (Python committer) Date: 2006-07-10 20:34
Logged In: YES 
user_id=344921

Bug 1376309 has been marked as a duplicate of this bug. 
msg25583 - (view) Author: Peter Åstrand (astrand) * (Python committer) Date: 2006-07-10 22:53
Logged In: YES 
user_id=344921

If we fix this before Python 2.5, I guess we don't need to
think about backwards compatibility. See the attached patch
for a suggested solution. 
msg25584 - (view) Author: Michael Hoffman (hoffman) Date: 2006-07-11 08:16
Logged In: YES 
user_id=987664

+1 from me. Thanks.
msg25585 - (view) Author: Anthony Baxter (anthonybaxter) (Python triager) Date: 2006-07-14 03:48
Logged In: YES 
user_id=29957

Sounds fine. Please make sure to add a NEWS entry!
msg25586 - (view) Author: Peter Åstrand (astrand) * (Python committer) Date: 2006-07-14 14:05
Logged In: YES 
user_id=344921

Fixed in revision 50638.
History
Date User Action Args
2022-04-11 14:56:11adminsetgithub: 42100
2005-06-20 06:56:52orenticreate