[Python-Dev] Exceptions *must*? be old-style classes?

Michael Hudson mwh at python.net
Tue Jan 18 18:00:45 CET 2005


"Martin v. Löwis" <martin at v.loewis.de> writes:

> Guido van Rossum wrote:
>>>>a) Is Exception to be new-style?
>>>
>>>Probably not in 2.5; Martin and others have suggested that this could
>>>introduce instability for users' existing exception classes.
>> Really? I thought that was eventually decided to be a very small
>> amount of code.
>
> I still think that only an experiment could decide: somebody should
> come up with a patch that does that, and we will see what breaks.
>
> I still have the *feeling* that this has significant impact, but
> I could not pin-point this to any specific problem I anticipate.

Well, some code is certainly going to break such as this from
warnings.py:

    assert isinstance(category, types.ClassType), "category must be a class"

or this from traceback.py:

    if type(etype) == types.ClassType:
        stype = etype.__name__
    else:
        stype = etype

I hope to have a new patch (which makes PyExc_Exception new-style, but
allows arbitrary old-style classes as exceptions) "soon".  It may even
pass bits of "make test" :)

Cheers,
mwh

-- 
  SPIDER:  'Scuse me. [scuttles off]
  ZAPHOD:  One huge spider.
    FORD:  Polite though.
                   -- The Hitch-Hikers Guide to the Galaxy, Episode 11


More information about the Python-Dev mailing list