[Python-Dev] PEP 352 Transition Plan
Guido van Rossum
guido at python.org
Sat Nov 5 18:46:54 CET 2005
> [Guido van Rossum]
> > I've made a final pass over PEP 352, mostly fixing the __str__,
> > __unicode__ and __repr__ methods to behave more reasonably. I'm all
> > for accepting it now. Does anybody see any last-minute show-stopping
> > problems with it?
> I did not follow the thread, so maybe I'm out in order, be kind with me.
> After having read PEP 352, it is not crystal clear whether in:
> the "except:" will mean "except BaseException:" or "except Exception:".
> I would except the first, but the text beginning the section titled
> "Exception Hierarchy Changes" suggests it could mean the second, without
> really stating it.
This is probably a leftover from PEP 348, which did have a change for
bare 'except:' in mind. PEP 352 doesn't propose to change its meaning,
and if there are words that suggest this, they should be removed.
Until Python 3.0, it will not change its meaning from what it is now;
this is because until then, it is still *possible* (though it will
become deprecated behavior) to raise string exceptions or classes that
don't inherit from BaseException.
> Let me argue that "except BaseException:" is preferable. First, because
> there is no reason to load a bare "except:" by anything but a very
> simple and clean meaning, like the real base of the exception hierarchy.
> Second, as a bare "except:" is not considered good practice on average,
> it would be counter-productive trying to figure out ways to make it more
> frequently _usable_.
What bare 'except:' will mean in Python 3.0, and whether it is even
allowed at all, is up for discussion -- it will have to be a new PEP.
Personally, I think bare 'except:' should be removed from the language
in Python 3.0, so that all except clauses are explicit in what they
catch and there isn't any confusion over whether KeyboardInterrupt,
SystemExit etc. are included or not.
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-Dev