[Python-Dev] Bare except clauses in PEP 348
raymond.hettinger at verizon.net
Wed Aug 24 21:15:12 CEST 2005
[Guido van Rossum]
> > OK, I'm convinced. Let's drop bare except for Python 3.0, and
> > deprecate them until then, without changing the meaning.
> > The deprecation message (to be generated by the compiler!) should
> > steer people in the direction of specifying one particular exception
> > (e.g. KeyError etc.) rather than Exception.
[James Y Knight]
> I agree but there's the minor nit of non-Exception exceptions.
> I think it must be the case that raising an object which does not
> derive from an exception class must be deprecated as well in order
> for "except:" to be deprecated. Otherwise, there is nothing you can
> change "except:" to in order not to get a deprecation warning and
> still have your code be correct in the face of documented features of
Hmm, that may not be a killer. I wonder if it is possible to treat
BaseException as a constant (like we do with None) and teach the
compiler to interpret it as catching anything that gets raised so that
"except BaseException" will work like a bare except clause does now.
More information about the Python-Dev