[Python-Dev] urllib exception compatibility

Greg Ewing greg.ewing at canterbury.ac.nz
Thu Sep 27 04:54:51 CEST 2007


Jim Jewett wrote:
> In particular, should socket.error, ftp.Error and
> httplib.HTTPException (used in Py3K) inherit from IOError?

I'd say that if they incorporate a C library result code they
should inherit from IOError, or if they incorporate a system
call result code they should inherit from OSError. Otherwise
they should inherit from EnvironmentError.

I don't think there's any point in simply catching one of
these and re-wrapping it in the library's own exeption
class, but if such wrapping is done, it should inherit
from EnvironmentError as well.

It's convenient to be able to catch EnvironmentError and
get anything that is caused by circumstances outside the
program's control.

-- 
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | Carpe post meridiem!          	  |
Christchurch, New Zealand	   | (I'm not a morning person.)          |
greg.ewing at canterbury.ac.nz	   +--------------------------------------+


More information about the Python-Dev mailing list