On Fri, 2002-10-04 at 08:21, Guido van Rossum wrote:
What would be nice is a way to define in Python a kind of exception that is not caught by bare "except:" statements but only by "except SpecificClass:" statements. Not quite an uncatchable exception, but one that is caught only by except statements that name it.
I'm skeptical about this one. Can you explain the use case?
I am too. ;-) Zope (for better or worse) uses the same machinery that users use in scripts and templates to deal with exceptional conditions (ConflictError, Unauthorized, etc). It should not be possible for users to catch these kinds of errors in Python Scripts and/or TAL. The two "exception domains" should really be divorced in some way. How about "goto"? ;-) Just kidding.
You can probably fake this to a large extent by using "except Exception:" instead of "except:" everywhere; then you can raise an exception that does not inherit from Exception.
This is probably the thing to do. - C