[Zope-dev] BUG: ValueError while changing height of the template edit window

Steve Alexander steve@cat-box.net
Wed, 11 Dec 2002 15:44:43 +0000


> Anything can raise MemoryError.

Ok. But I don't think regular application code should catch these.


> On converting an 8bit string to an int:
> 
>      ValueError *only*

Ok.

> On converting a Unicode string to an int:
> 
>      ValueError
>      UnicodeError (or UnicodeEncodeError, which is a subclass of it)

Can you provide an example of raising a unicode error like this:

   u = makeUnicodeString()  # your choice of function
   int(u)

My point is that once you have a valid unicode object, I don't see how 
calling int(valid_unicode_object) will raise a UnicodeError.

If this is so, then the style should be:

   value = expression_to_compute_value
   try:
       i = int(value)
   except ValueError:
       # take corrective action

rather than:

   try:
       i = int(expression_to_compute_value)
   except:  # Note: calling 'int()' can raise just about anything
       # take corrective action


--
Steve Alexander