[Python-Dev] Pre-PEP: Exception Reorganization for Python 3.0

Willem Broekema metawilm at gmail.com
Tue Aug 2 21:39:49 CEST 2005


On 8/2/05, Stephen J. Turnbull <stephen at xemacs.org> wrote:
> I don't see it that way.  Rather, "Raisable" is the closest equivalent
> to "serious-condition", and "CriticalException" is an intermediate
> class that has no counterpart in Lisp usage.

That would imply that all raisables are 'serious' in the Lisp sense,
which is defined as "all conditions serious enough to require
interactive intervention if not handled". Yet Python warnings are
raisable (as raisable is the root), but are certainly not serious in
the Lisp sense.

(This is complicated by that warnings are raised using 'signal'. More below.)

Willem:
> I'd prefer the 'condition' and 'error' terminology, and to
> label a keyboard interrupt a condition, not any kind of
> exception or error.

To clarify myself: a 'serious-condition' in CL stands for "all
conditions serious enough to require interactive intervention if not
handled"; I meant to label KI a 'serious-condition'.

Stephen: 
> Now, that does bother me.<wink>  Anything we will not permit a program
> to ignore with a bare "except: pass" if it so chooses had better be
> more serious than merely a "condition".  Also, to me a "condition" is
> something that I poll for, it does not interrupt me.  To me, a
> condition (even a serious one) is precisely the kind of thing that I
> should be able to ignore with a bare except!

If I understand your position correctly, it is probably not changed
yet by the above clarification. <wink>

Maybe it will surprise you, that in Lisp a bare except (ignore-errors)
does not catch non-serious things like warnings. And if left
uncatched, a warning leaks out to the top level, gets printed and
subsequently ignored. That's because non-serious conditions are
(usually) raised using 'signal', not 'error'. The default top-level
warnings handler just prints it, but does not influence the program
control flow, so the execution resumes just after the (warn ..) form.

This probably marks a very important difference between Python and CL.
I think one could say that where in Python one would use a bare except
to catch both non-serious and serious exceptions, in CL one normally
doesn't bother with catching the non-serious ones because they will
not create havoc at an outer level anyway. So in Python a warning must
be catched by a bare except, while in Lisp it would not. And from this
follow different contraints on the hierarchy.

By the way, this is the condition hierarchy in Allegro CL (most of
which is prescribed by the ANSI standard):
<http://www.franz.com/support/documentation/7.0/doc/errors.htm>


- Willem


More information about the Python-Dev mailing list