Class based built-in exception hierarchy.
New with Python 1.5, all standard built-in exceptions are now class objects by
default. This gives Python's exception handling mechanism a more
object-oriented feel. Traditionally they were string objects. Python will
fallback to string based exceptions if the interpreter is invoked with the -X
option, or if some failure occurs during class exception initialization (in
this case a warning will be printed).
Most existing code should continue to work with class based exceptions. Some
tricky uses of IOError may break, but the most common uses should work.
Here is a rundown of the class hierarchy. You can change this by editing this
file, but it isn't recommended because the old string based exceptions won't
be kept in sync. The class names described here are expected to be found by
the bltinmodule.c file. If you add classes here, you must modify
bltinmodule.c or the exceptions won't be available in the __builtin__ module,
nor will they be accessible from C.
The classes with a `*' are new since Python 1.5. They are defined as tuples
containing the derived exceptions when string-based exceptions are used. If
you define your own class based exceptions, they should be derived from
Exception.
Exception(*)
|
+-- SystemExit
+-- StandardError(*)
|
+-- KeyboardInterrupt
+-- ImportError
+-- EnvironmentError(*)
| |
| +-- IOError
| +-- OSError(*)
|
+-- EOFError
+-- RuntimeError
| |
| +-- NotImplementedError(*)
|
+-- NameError
+-- AttributeError
+-- SyntaxError
+-- TypeError
+-- AssertionError
+-- LookupError(*)
| |
| +-- IndexError
| +-- KeyError
|
+-- ArithmeticError(*)
| |
| +-- OverflowError
| +-- ZeroDivisionError
| +-- FloatingPointError
|
+-- ValueError
+-- SystemError
+-- MemoryError