new style exception handleing

Ola Natvig ola.natvig at infosense.no
Thu Feb 3 03:33:51 EST 2005


Peter Hansen wrote:
> Ola Natvig wrote:
> 
>> Does anybody know why it's not possible to raise Exceptions which are 
>> types (new-style-classes). I know all standard exceptions are classic 
>> classes, but if you make a custom exception which both inherits from a 
>> exception class and a new-style one the it causes a type error when 
>> raised.
>>
>>  >>> class b(Exception, object): pass
> 
> 
> This might not help you, but have you considered just making
> your old-style class *contain a reference* to an instance
> of whatever new-style class you want it to contain?  Then
> the issue goes away.
> 
> I can't actually think of a reason to need to base an
> exception on a new-style class, but perhaps you have a
> good one...
> 
> -Peter

It's quite simple to bypass the problem, it was more the reason I was 
wondering about too.

-- 
--------------------------------------
  Ola Natvig <ola.natvig at infosense.no>
  infoSense AS / development



More information about the Python-list mailing list