[Python-Dev] Bare except clauses in PEP 348
Scott David Daniels
Scott.Daniels at Acm.Org
Thu Aug 25 19:30:22 CEST 2005
Raymond Hettinger wrote:
>... I propose that the transition plan be as simple as introducing
> BaseException. This allows people to write code that will work on both
> 2.x and 3.0. It doesn't break anything.
>
> The guidance for cross-version (2.5 to 3.0) code would be:
>
> * To catch all but terminating exceptions, write:
>
> except (KeyError, SystemExit):
> raise
> except Exception:
> ...
How about:
except BaseException, error:
if not isinstance(error, Exception):
raise
...
This would accommodate other invented exceptions such as
"FoundConvergance(BaseException)", which is my pseudo-example
for an exiting exception that is not properly a subclass of
either KeyError or SystemExit. The idea is a relaxation stops
when it doesn't move and may start generating something silly
like divide-by-zero. Not the end of an App, but the end of a Phase.
--Scott David Daniels
Scott.Daniels at Acm.Org
More information about the Python-Dev
mailing list