[Zope3-dev] Please, no bare 'except:' clauses!

Chris Withers chrisw@nipltd.com
Tue, 12 Nov 2002 11:13:07 +0000


Shane Hathaway wrote:
>>
>> Let's see, int() can raise TypeError and ValueError.  What else?
> 
> Anything.
> 
>  >>> class m:
> ...   def __int__(self):
> ...     return sadf
> ...
>  >>> int(m())
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>   File "<stdin>", line 3, in __int__
> NameError: global name 'sadf' is not defined
> 
> :-)

But surely by that logic, pretty much any operation can raise any exception?

Personally, I feel the able error shouldn't be caught anyway, as it's a 
programming error in class m ,which should raise a ValueError.

cheers,

Chris - anyone for declaring what you can throw? ;-)