Exceptions as New Style Classes

Andrew zuckuss at apexmail.com
Wed Jul 30 18:30:45 CEST 2003


Hi,
To satisfy my curiosity I was wondering if anyone knew if this
behaviour was intentional?
Is there a specific reason why exceptions are not allowed to be new
style classes?

Python 2.3 (#46, Jul 29 2003, 18:54:32) [MSC v.1200 32 bit (Intel)] on
win32
>>> class OldException: pass
>>> raise OldException()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
__main__.OldException: <__main__.OldException instance at 0x006AC490>

>>> class NewException(object): pass
>>> raise NewException()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: exceptions must be classes, instances, or strings
(deprecated), not NewException




More information about the Python-list mailing list