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

Phillip J. Eby pje at telecommunity.com
Mon Jan 17 19:34:30 CET 2005


At 10:16 AM 1/17/05 -0800, Guido van Rossum wrote:
>On Mon, 17 Jan 2005 11:35:53 -0500, Phillip J. Eby
><pje at telecommunity.com> wrote:
> > At 04:06 PM 1/17/05 +0000, Michael Hudson 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.

Guess I missed that part of the thread in the ongoing flood of PEP 246 
stuff.  :)


>That would be much more reasonable if Exception itself was a new-style
>class. As long as it isn't, you'd have to declare new-style classes
>like this:
>
>class MyError(Exception, object):
>     ...
>
>which is ugly.

I was thinking the use case was that you were having to add 'Exception', 
not that you were adding 'object'.  The two times in the past that I wanted 
to make a new-style class an exception, I *first* made it a new-style 
class, and *then* tried to make it an exception.  I believe the OP on this 
thread described the same thing.

But whatever; as long as it's *possible*, I don't care much how it's done, 
and I can't think of anything in my code that would break from making 
Exception new-style.



More information about the Python-Dev mailing list