All standard Python exceptions are available as global variables whose
names are "PyExc_" followed by the Python exception name. These
have the type PyObject*; they are all either class objects or
string objects, depending on the use of the -X option to the
interpreter. For completeness, here are all the variables:
| C Name | Python Name | Notes |
|---|---|---|
| Exception | (1) | |
| StandardError | (1) | |
| ArithmeticError | (1) | |
| LookupError | (1) | |
| AssertionError | ||
| AttributeError | ||
| EOFError | ||
| EnvironmentError | (1) | |
| FloatingPointError | ||
| IOError | ||
| ImportError | ||
| IndexError | ||
| KeyError | ||
| KeyboardInterrupt | ||
| MemoryError | ||
| NameError | ||
| NotImplementedError | ||
| OSError | ||
| OverflowError | ||
| RuntimeError | ||
| SyntaxError | ||
| SystemError | ||
| SystemExit | ||
| TypeError | ||
| ValueError | ||
| ZeroDivisionError |
Note:
-X interpreter option is used, these will be tuples
containing the string exceptions which would have otherwise been
subclasses.