[Python-Dev] PEP, take 2: Exception Reorganization for Python 3.0
mwh at python.net
Wed Aug 3 22:13:43 CEST 2005
Guido van Rossum <gvanrossum at gmail.com> writes:
> So here's a radical proposal (hear the scratching of the finglernail
> on the blackboard? :-).
> Start with Brett's latest proposal. Goal: keep bare "except:" but
> change it to catch only the part of the hierarchy rooted at
> - Call the root of the hierarchy Raisable.
> - Rename CriticalException to CriticalError
> (this should happen anyway).
> - Rename ControlFlowException to ControlFlowRaisable
> (anything except Error or Exception).
> - Rename StandardError to Exception.
> - Make Warning a subclass of Exception.
> I'd want the latter point even if the rest of this idea is rejected;
> when a Warning is raised (as opposed to just printing a message or
> being suppressed altogether) it should be treated just like any other
> normal exception, i.e. StandardError.
In the above you need to ensure that all raised exceptions inherit
from Raisable, because sometimes you really do want to catch almost
anything (e.g. code.py).
Has anyone thought about the C side of this? There are a few
slightly-careless calls to PyErr_Clear() in the codebase, and they can
cause just as much (more!) heartache as bare except: clauses.
I'll note in passing that I'm not sure that any reorganization of the
exception hierachy will make this kind of catching-too-much bug go
away. The issue is just thorny, and each case is different.
I'm also still not convinced that the backwards compatibility breaking
Python 3.0 will ever actually happen, but I guess that's a different
Haha! You had a *really* weak argument! <wink>
-- Moshe Zadka, comp.lang.python
More information about the Python-Dev