[Python-Dev] urllib exception compatibility
Jim Jewett
jimjjewett at gmail.com
Thu Sep 27 02:35:36 CEST 2007
urllib goes to goes to some trouble to ensure that it raises IOError,
even when the underlying exception comes from another module.[*] I'm
wondering if it would make sense to just have those modules'
exceptions inherit from IOError.
In particular, should socket.error, ftp.Error and
httplib.HTTPException (used in Py3K) inherit from IOError?
I'm also wondering whether it would be acceptable to change the
details of the exceptions. For example, could
raise IOError, ('ftp error', msg), sys.exc_info()[2]
be reworded, or is there there too much risk that someone is checking
for an "errno" of 'ftp error'?
[*] This isn't a heavily tested path; some actually fail with a
TypeError since 2.5, because IOError no longer accepts argument tuples
longer than 3. http://bugs.python.org/issue1209 Fortunately, this
makes me less worried about changing the contents of the specific
attributes to something more useful...
-jJ
More information about the Python-Dev
mailing list