On 2005 Jan 16, at 10:28, Martin v. Löwis wrote:

Phillip J. Eby wrote:
Couldn't we require new-style exceptions to inherit from Exception? Since there are no new-style exceptions that work now, this can't break existing code.

This would require to make Exception a new-style class, right?

Not necessarily, since Python supports multiple inheritance:

class MyException(Exception, object): .....

there -- a newstyle exception class inheriting from oldstyle Exception. (ClassType goes to quite some trouble to allow this, getting the metaclass from _following_ bases if any).

Without inheritance you might similarly say:

class AnotherOne(Exception):
    __metaclass__ = type
    ...

This, in itself, could break existing code.

Not necessarily, see my previous post. But anyway, PJE's proposal is less invasive than making Exception itself newstyle.



Alex

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to