[Zope-dev] ConflictError shouldn't subclass Exception

Chris McDonough chrism at plope.com
Fri Nov 25 15:51:47 EST 2005


On Nov 25, 2005, at 2:25 PM, Patrick Gerken wrote:

> 2005/11/24, Chris Withers <chris at simplistix.co.uk>:
>> Interestingly, you can raise things that don't subclass Exception in
>> python. This was discussed before, and I firmly agree with, that zodb
>> conflicts should _not_ sublcass exception. That way, there's less  
>> chance
>> of them being caught by inexperienced programmers putting in try:  
>> except
>> Exception: 's.
>>
>> How would we go about making this change?
>
> class my_own_exception:
>   pass
>
> try:
>   raise my_own_exception()
> except:
>   print "Doesn't help against inexperienced programmers. sadly"
>
> You can even raise a string, which is accidently done in zope2 and
> where my with provided solution and unit test is pending.
> It is better to beat people using except: without good reasons.

Yup.  Lots of talk has been going on on python-dev about putting  
exceptions into multiple hierarchies lately, which would solve the  
problem at the right level.

- C




More information about the Zope-Dev mailing list