Table B.12 lists exceptions in Python.
Table B.12. Python Built-In Exceptions
Exception Name | Description |
---|
BaseException[a] | Root class for all exceptions |
SystemExit[b]
| Request termination of Python interpreter |
KeyboardInterrupt[c]
| User interrupted execution (usually by typing ^C) |
Exception[d]
| Root class for regular exceptions |
StopIteration[e]
| Iteration has no further values |
GeneratorExit[a]
| Exception sent to generator to tell it to quit |
SystemExit[f]
| Request termination of Python interpreter |
StandardError[d]
| Base class for all standard built-in exceptions |
ArithmeticError[d]
| Base class for all numeric calculation errors |
FloatingPointError[d]
| Error in floating point calculation |
OverflowError
| Calculation exceeded maximum limit for numerical type |
ZeroDivisionError
| Division (or modulus) by zero error (all numeric types) |
AssertionError[d]
| Failure of assert statement |
AttributeError
| No such object attribute |
EOFError
| End-of-file marker reached without input from built-in |
EnvironmentError
| Base class for operating system environment errors |
IOError
| Failure of input/output operation |
OSError
| Operating system error |
WindowsError
| MS Windows system call failure |
ImportError
| Failure to import module or object |
KeyboardInterrupt[f]
| User interrupted execution (usually by typing ^C) |
LookupError[d]
| Base class for invalid data lookup errors |
IndexError
| No such index in sequence |
KeyError
| No such key in mapping |
MemoryError
| Out-of-memory error (non-fatal to Python interpreter) |
NameError
| Undeclared/uninitialized object (non-attribute) |
UnboundLocalError
| Access of an uninitialized local variable |
ReferenceError
| Weak reference tried to access a garbage-collected object |
RuntimeError
| Generic default error during execution |
NotImplementedError
| Unimplemented method |
SyntaxError
| Error in Python syntax |
IndentationError
| Improper indentation |
TabError[g]
| Improper mixture of TABs and spaces |
SystemError
| Generic interpreter system error |
TypeError
| Invalid operation for type |
ValueError
| Invalid argument given |
UnicodeError[h]
| Unicode-related error |
UnicodeDecodeError
| Unicode error during decoding |
UnicodeEncodeError
| Unicode error during encoding |
UnicodeTranslate
| Unicode error during translation |
Error[i] | |
Warning[j]
| Root class for all warnings |
DeprecationWarning[j]
| Warning about deprecated features |
FutureWarning[i]
| Warning about constructs that will change semantically in the future |
OverflowWarning[k]
| Old warning for auto-long upgrade |
PendingDeprecationWarning[i]
| Warning about features that will be deprecated in the future |
RuntimeWarning[j]
| Warning about dubious runtime behavior |
SyntaxWarning[j]
| Warning about dubious syntax |
UserWarning[j]
| Warning generated by user code |