[Python-Dev] Pre-PEP: Exception Reorganization for Python 3.0

Brett Cannon bcannon at gmail.com
Tue Aug 2 18:56:05 CEST 2005

On 8/2/05, Phillip J. Eby <pje at telecommunity.com> wrote:
> At 08:00 PM 8/2/2005 +1000, Nick Coghlan wrote:
> Or maybe we
> should just make the primary hierarchy the way we want it to be, and only
> cross-link exceptions to StandardError that were previously under
> StandardError, i.e.:
>      Raisable
>          ControlFlowException
>              ...  (cross-inherit to StandardError as needed)
>          CriticalError
>              ...  (cross-inherit to StandardError as needed)
>          Exception
>              ...
> This wouldn't avoid "except Exception" and bare except being problems, but
> at least you can catch the uncatchables and reraise them.

I think that is acceptable.  Using multiple inheritance to make sure
that the exceptions that have been moved out of the main exception
branch seems like it will be the best solution for giving some form of
backwards-compatibility for now while allowing things to still move
forward and not cripple the changes we want to make.

> Hm.  Maybe we should include a Reraisable base for ControlFlowException and
> CriticalError?  Then you could do "except Reraisable: raise" as a nice way
> to do the right thing until Python 3.0.

As in exceptions that don't inherit from
Error/StandError/whatever_the_main_exception_is can easily be caught

> It seems to me that multiple inheritance is definitely the right idea,
> though.  That way, we can get the hierarchy we really want with only a
> minimum of boilerplate in pre-3.0 to make it actually work.

Yeah.  I think name aliasing and multiple inheritance will take us a
long way.  Warnings should be able to take us the rest of the way.

-Brett (who is still waiting for a number; Barry, David, you out there?)

More information about the Python-Dev mailing list