Please leave IOError and OSError aloneFrom Lawrence Oluyede's blog entry about recent Python SVN updates:
Augh. Wait, that's not strong enough, let me try again: AUGH. In fact, it gets worse. To quote from the urrlib2 SVN source
code's comment about its
(urllib2 also directly raises mis-formatted Python's What these people have done, whether they realize it or not, is to turn
IOError exception objects into nothing more than strings, because
these modules have insured that there is no higher structure that you
can count on an IOError instance having. Unfortunately the relevant
Python documentation
does not mention this, and continues to mislead the innocent into
believing that when they catch an IOError exception they can do useful
things like look at its Or, to boil it down: never raise or subclass IOError, OSError, or EnvironmentError. (This applies to The only exception is if you are somehow directly calling a C library
function (that is documented as setting To my horror, urllib2 is hardly the only offender; there are even some in C level modules (in bz2module.c and zipimport.c). But that doesn't excuse them making the situation worse; in fact they should be moving towards making the situation better. Even with backwards compatibility concerns they could have raised URLError instead of IOError directly (or taken the opportunity to introduce a proper error class if they felt URLError was inapplicable). (This rant has been brought to you by my attempt to catch up on Planet Python.) (One comment.)
|
These are my WanderingThoughts GettingAround This is part of CSpace, and is written by ChrisSiebenmann. * * * Atom feeds are available; see the bottom of most pages. Categories: links, linux, programming, python, snark, solaris, spam, sysadmin, tech, unix, web |