[Python-Dev] Re: Dangerous exceptions (was Re: Another
test_compilermystery)
Jeremy Hylton
jhylton at gmail.com
Tue Sep 7 16:07:25 CEST 2004
On Tue, 07 Sep 2004 09:43:53 -0400, Jim Fulton <jim at zope.com> wrote:
> Jeremy Hylton wrote:
>
> ...
>
> > I
> > think it would be easier in principle to put them at a different place
> > in the class hierarchy than to make them some special kind of
> > uncatchable exception.
>
> Note that we don't want uncatchable exceptions. Rather, we want
> exceptions that aren't caught by bare excepts or very broad
> excepts. In many cases, we want certain knowledgeable code to be able
> to catch these exceptions.
I agree with half the cause. There ought to be a decent organization
of the exception class hierarchy so that exceptions like
KeyboardInterrupt are in a special category. Then an "except
NormalError:" <wink> would catch only the normal errors and not the
special ones. I don't think bare exception should change it's
meaning; you just shouldn't use it unless it's *really* what you mean.
I think backwards compatibility is a really hard issue for any of
these changes. It's probably hard to re-arrange the class hierarchy,
but I don't know what practical solution there is to these problems
that doesn't involve breaking some code. It's even harder to change
bare except, but I don't think that's necessary.
Jeremy
More information about the Python-Dev
mailing list