[Python-Dev] PEP, take 2: Exception Reorganization for Python 3.0

Brett Cannon bcannon at gmail.com
Wed Aug 3 19:44:30 CEST 2005


On 8/3/05, Guido van Rossum <gvanrossum at gmail.com> wrote:
> So here's a radical proposal (hear the scratching of the finglernail
> on the blackboard? :-).
> 
> Start with Brett's latest proposal.

Including renaming (I want to know if you support the renamings at
all, if I should make them more of an idea to be considered when we
get closer to Python 3.0, or just drop them) and the new exceptions?

> Goal: keep bare "except:" but
> change it to catch only the part of the hierarchy rooted at
> StandardError.
> 

Why the change of heart?  Backwards-compatibility?  Way to keep
newbies from choosing Raisable or such as what to catch?

> - Call the root of the hierarchy Raisable.

Fine by me.  Will change it before I check in the PEP tonight.

> - Rename CriticalException to CriticalError
>   (this should happen anyway).

I thought I changed that in the latest version.  I will change it.

> - Rename ControlFlowException to ControlFlowRaisable
>   (anything except Error or Exception).

No objection from me.

> - Rename StandardError to Exception.

So just ditch StandardError, which is fine by me, or go with Nick's v2
proposal and have all pre-existing exceptions inherit from it?  I
assume the latter since you said you wanted bare 'except' clauses to
catch StandardError.

> - 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.
> 

Since warnings only become raised if the warnings filter lists it as
an error I can see how this is a reasonable suggestion.  And if bare
'except' clauses catch StandardError and not Exception they will still
propagate to the top unless people explicitly catch Exception or lower
which seems fair.

-Brett


More information about the Python-Dev mailing list