Yurttas/PL/SL/python/docs/core-python-programming/doc/16/api/standardExceptions.html

From ZCubes Wiki
Jump to navigation Jump to search


4.1 Standard Exceptions

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 class objects. For completeness, here are all the variables:

C Name Python Name Notes

PyExc_Exception

Exception (1)

PyExc_StandardError

StandardError (1)

PyExc_ArithmeticError

ArithmeticError (1)

PyExc_LookupError

LookupError (1)

PyExc_AssertionError

AssertionError

PyExc_AttributeError

AttributeError

PyExc_EOFError

EOFError

PyExc_EnvironmentError

EnvironmentError (1)

PyExc_FloatingPointError

FloatingPointError

PyExc_IOError

IOError

PyExc_ImportError

ImportError

PyExc_IndexError

IndexError

PyExc_KeyError

KeyError

PyExc_KeyboardInterrupt

KeyboardInterrupt

PyExc_MemoryError

MemoryError

PyExc_NameError

NameError

PyExc_NotImplementedError

NotImplementedError

PyExc_OSError

OSError

PyExc_OverflowError

OverflowError

PyExc_RuntimeError

RuntimeError

PyExc_SyntaxError

SyntaxError

PyExc_SystemError

SystemError

PyExc_SystemExit

SystemExit

PyExc_TypeError

TypeError

PyExc_ValueError

ValueError

PyExc_ZeroDivisionError

ZeroDivisionError

Note:

(1)
This is a base class for other standard exceptions. If the -X interpreter option is used, these will be tuples containing the string exceptions which would have otherwise been subclasses.