[Zope3-dev] Re: [Zope-dev] Re: tal:on-error is a bare except...
Tres Seaver
tseaver at zope.com
Mon Aug 23 14:56:44 EDT 2004
Jim Fulton wrote:
> Tres Seaver wrote:
>
>> Jim Fulton wrote:
>>
>
> ...
>
>>> Hm. I wonder if SystemError would be appropriate here.
>>> (Zope may abuse SystemError, but we could fix that.)
>>
>>
>>
>> RuntimeError exists, but has the wrong bases (StandardError, which
>> derives from Exception). SystemError has StandardError as its base, too.
>
>
> I'm not trying to solve the problem of making an exception uncatchable.
> If we said that RuntimeError or SystemError (or whatever) shouldn't
> be caught by a bare excpt, then we could, with present Python
> say that the following is the correct idiom for a bare except:
>
> try:
> ...
> except:
> if isinstance(sys.exc_info()[1], RuntimeError):
> raise
> ... do what we do for ctachable errors
OK. I think the spelling would be better as follows:
try:
...
except RuntimeError: # I'm not smart enough to catch these
raise
except:
....
That is how most of the "sprinkled" ConflictError checks look in Zope2
code, anyway.
Tres.
--
===============================================================
Tres Seaver tseaver at zope.com
Zope Corporation "Zope Dealers" http://www.zope.com
More information about the Zope3-dev
mailing list