[ python-Bugs-1223937 ] subprocess.py abuse of errno

SourceForge.net noreply at sourceforge.net
Fri Jul 14 16:05:05 CEST 2006


Bugs item #1223937, was opened at 2005-06-20 08:56
Message generated for change (Comment added) made by astrand
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1223937&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.5
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Oren Tirosh (orenti)
Assigned to: Peter Ã
strand (astrand)
Summary: subprocess.py abuse of errno

Initial Comment:
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.


----------------------------------------------------------------------

>Comment By: Peter Ã
strand (astrand)
Date: 2006-07-14 16:05

Message:
Logged In: YES 
user_id=344921

Fixed in revision 50638.

----------------------------------------------------------------------

Comment By: Anthony Baxter (anthonybaxter)
Date: 2006-07-14 05:48

Message:
Logged In: YES 
user_id=29957

Sounds fine. Please make sure to add a NEWS entry!


----------------------------------------------------------------------

Comment By: Michael Hoffman (hoffmanm)
Date: 2006-07-11 10:16

Message:
Logged In: YES 
user_id=987664

+1 from me. Thanks.

----------------------------------------------------------------------

Comment By: Peter Ã
strand (astrand)
Date: 2006-07-11 00:53

Message:
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. 

----------------------------------------------------------------------

Comment By: Peter Ã
strand (astrand)
Date: 2006-07-10 22:34

Message:
Logged In: YES 
user_id=344921

Bug 1376309 has been marked as a duplicate of this bug. 

----------------------------------------------------------------------

Comment By: Peter Ã
strand (astrand)
Date: 2005-06-21 22:13

Message:
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. 

----------------------------------------------------------------------

Comment By: Peter Ã
strand (astrand)
Date: 2005-06-21 17:52

Message:
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.)

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1223937&group_id=5470


More information about the Python-bugs-list mailing list