[Zope3-dev] Please, no bare 'except:' clauses!
Barry A. Warsaw
barry@zope.com
Mon, 11 Nov 2002 13:06:23 -0500
>>>>> "JH" == Jeremy Hylton <jeremy@zope.com> writes:
JH> This is sufficient for dealing with sloppy exception handling,
JH> though. If the transaction is read-only and the except clause
JH> swallows a ReadConflictError, the app may never find out that
JH> a consistency problem occurred.
JH> Thinking more... I suppose a Connection could have a
JH> per-transaction marker that says it has detected a read
JH> conflict. If the marker is set, it could refuse to load any
JH> more objects. That sounds a bit draconian. I'm not sure what
JH> makes sense.
Won't multiversion concurrency control eliminate read conflicts?
JH> There are very few places where bare except is needed. At
JH> least some of those places, the bare except is in place
JH> because it's very hard to tell what exception Python might
JH> raise (calling int() is an example). In cases like that, the
JH> StandardError solution is a good one.
Let's see, int() can raise TypeError and ValueError. What else?
-Barry