[Python-Dev] Proposal - KeyboardInterrupt should inherit directly from Exception

Barry A. Warsaw barry@zope.com
Thu, 8 Nov 2001 10:18:55 -0500


>>>>> "SM" == Skip Montanaro <skip@pobox.com> writes:

    SM> Yeah, that's why I didn't ask "I know we're in feature freeze,
    SM> but can we please please please make this one itty bitty
    SM> change? Please please please?  Did I forget to mention please
    SM> please please?"  ;-)

:)

    BAW> I do stuff like this all the time, although it's usually
    BAW> OSError.  I love that OSError and IOError have a common base
    BAW> class!  I've often wanted all the errno's to be transformed
    BAW> into subclasses of IOError/OSError, so I could just do
    BAW> something like:

    BAW> try: os.mkdir(...)  except OSErrorEEXIST: pass # any other
    BAW> OSError propagates up

    SM> Why not make them all subclasses of OSError that are also
    SM> attributes of the OSError class.  You'd then have

    |     try:
    |        os.mkdir(...)
    |     except OSError.EEXIST:
    |        pass
    |     # any other OSError propagates up

    SM> which seems a little less builtin namespace polluting to me.
    SM> After all, there are quite a few signals, yes?

Y'know, that's got a certain appeal, although perhaps they ought to be
added to EnvironmentError, since I think most can show up as a result
of both IOError and OSError.  Hmm, okay, I work this up and squeeze it
into Python 2.2...

...just kidding. :)  But it'd be worth looking into for Py2.3.

-Barry