[Python-Dev] Exception Reorg PEP checked in

Nick Coghlan ncoghlan at gmail.com
Thu Aug 4 13:03:05 CEST 2005


Brett Cannon wrote (in the PEP):
> KeyboardInterrupt inheriting from ControlFlowException
> 
> KeyboardInterrupt has been a contentious point within this hierarchy. Some
> view the exception as more control flow being caused by the user. But with
> its asynchronous cause thanks to the user being able to trigger the
> exception at any point in code it has a more proper place inheriting from
> CriticalException. It also keeps the name of the exception from being
> "CriticalError".

I think this argues against your own hierarchy, since you _did_ call the 
parent exception CriticalError. By your argument above, that suggests 
KeyboardInterrupt doesn't belong there ;)

In practice, whether KeyboardInterrupt inherits from ControlFlowException or 
CriticalError shouldn't be a big deal - the important thing is to get it out 
from under Exception and StandardError.

At which point, the naming issue is enough to incline me towards christening 
it a ControlFlowException. It gets all the 'oddly named' exceptions into one 
place.

Additionally, consider that a hypothetical ThreadExit exception (used to 
terminate a thread semi-gracefully) would also clearly belong under 
ControlFlowException. That is, just because something is asynchronous with 
respect to the currently executing code doesn't necessarily make it an error 
(yes, I know I argued the opposite point the other day. . .).

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://boredomandlaziness.blogspot.com


More information about the Python-Dev mailing list