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

Robert Brewer fumanchu at amor.org
Sat Jul 30 05:07:45 CEST 2005


Brett Cannon wrote:
> New Hierarchy
> =============
> 
> Raisable (new; rename BaseException?)
> +-- CriticalException (new)
>     +-- KeyboardInterrupt
>     +-- MemoryError
>     +-- SystemExit
>     +-- SystemError (subclass SystemExit?)

I'd recommend not subclassing SystemExit--there are too many programs
out there which expect the argument (e.g. sys.exit(3)) to mean something
specific, but that expectation doesn't apply at all to SystemError.

> +-- Exception (replaces StandardError)
>...
>     +-- ControlFlowException (new)

I'd definitely appreciate ControlFlowException--there are a number of
exceptions in CherryPy which should subclass from that. Um, CherryPy
3.0, that is. ;)

>     +-- LookupError (better name?)

SubscriptError, perhaps? But LookupError could become the "I didn't find
obj X in the container you specified" superclass, in which case
LookupError is perfect.

>     +-- TypeError
>         +-- AttributeError (subclassing new)

"Since most attribute access errors can be attributed to an object not
being the type that one expects, it makes sense for AttributeError to
be considered a type error."

Very hmmm. I would have thought it would be a LookupError instead, only
because I favor the duck-typing parts of Python. Making AttributeError
subclass from TypeError leans toward stronger typing models a bit too
much, IMO.

>     +-- WeakReferenceError (rename for ReferenceError)

This also has a LookupError feel to it.

> It has been argued that Raisable is a bad name to use since it is not
> an actual word [python-dev1]_.

Perhaps, but compare http://www.onelook.com/?w=raisable to
http://www.onelook.com/?w=raiseable. The only sources "raiseable" has
going for it are Dictionary.com (which aggregates lots of questionable
sources), Rhymezone, and LookWAYup. I think "raisable" is the clear
winner.


Robert Brewer
System Architect
Amor Ministries
fumanchu at amor.org


More information about the Python-Dev mailing list