[Python-Dev] PEP, take 2: Exception Reorganization for Python 3.0
Guido van Rossum
gvanrossum at gmail.com
Wed Aug 3 21:00:58 CEST 2005
On 8/3/05, Brett Cannon <bcannon at gmail.com> wrote:
> 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?
Most of the renamings sound fine to me.
> > 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?
The proposal accepts that there's a need to catch "all errors that are
reasonable to catch": that's why it separates StandardError from the
root exception class.
So now we're going to recommend that everyone who was using bare
'except:' write 'except StandardError:' instead.
So why not have a default?
Because of EIBTI?
Seems a weak argument; we have defaults for lots of things.
> > - 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.
I may have missed the change.
> > - Rename ControlFlowException to ControlFlowRaisable
> > (anything except Error or Exception).
>
> No objection from me.
I actually find it ugly; but it's not an error and it would be weird
if there was an xxxException that didn't derive from Exception.
> > - 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.
What do you think? Of course the critical and control flow ones should
*not* inherit from it.
[...brain hums...]
OK, I'm changing my mind again about the names again.
Exception as the root and StandardError can stay; the only new
proposal would then be to make bare 'except:' call 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.
Unclear what you mean; I want bare except; to catch Warnings! IOW I
want Warning to inherit from whatever the thing is that bare except:
catches (if we keep it) and that is the start of all the "normal"
exceptions excluding critical and control flow exceptions.
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-Dev
mailing list