Exceptions¶
Python’s standard exception class hierarchy.
Exceptions found here are defined both in the exceptions module and the built-in namespace. It is recommended that user-defined exceptions inherit from Exception. See the documentation for the exception inheritance hierarchy.
-
exception
ArithmeticError
¶ Base class for arithmetic errors.
-
exception
AssertionError
¶ Assertion failed.
-
exception
AttributeError
¶ Attribute not found.
-
exception
BaseException
¶ Common base class for all exceptions
-
exception
BufferError
¶ Buffer error.
-
exception
BytesWarning
¶ Base class for warnings about bytes and buffer related problems, mostly related to conversion from str or comparing to str.
-
exception
DeprecationWarning
¶ Base class for warnings about deprecated features.
-
exception
EOFError
¶ Read beyond end of file.
-
exception
EnvironmentError
¶ Base class for I/O related errors.
-
errno
¶ exception errno
-
filename
¶ exception filename
-
strerror
¶ exception strerror
-
-
exception
Exception
¶ Common base class for all non-exit exceptions.
-
exception
FloatingPointError
¶ Floating point operation failed.
-
exception
FutureWarning
¶ Base class for warnings about constructs that will change semantically in the future.
-
exception
GeneratorExit
¶ Request that a generator exit.
-
exception
IOError
¶ I/O operation failed.
-
exception
ImportError
¶ Import can’t find module, or can’t find name in module.
-
exception
ImportWarning
¶ Base class for warnings about probable mistakes in module imports
-
exception
IndentationError
¶ Improper indentation.
-
exception
IndexError
¶ Sequence index out of range.
-
exception
KeyError
¶ Mapping key not found.
-
exception
KeyboardInterrupt
¶ Program interrupted by user.
-
exception
LookupError
¶ Base class for lookup errors.
-
exception
MemoryError
¶ Out of memory.
-
exception
NameError
¶ Name not found globally.
-
exception
NotImplementedError
¶ Method or function hasn’t been implemented yet.
-
exception
OSError
¶ OS system call failed.
-
exception
OverflowError
¶ Result too large to be represented.
-
exception
PendingDeprecationWarning
¶ Base class for warnings about features which will be deprecated in the future.
-
exception
ReferenceError
¶ Weak ref proxy used after referent went away.
-
exception
RuntimeError
¶ Unspecified run-time error.
-
exception
RuntimeWarning
¶ Base class for warnings about dubious runtime behavior.
-
exception
StandardError
¶ Base class for all standard Python exceptions that do not represent interpreter exiting.
-
exception
StopIteration
¶ Signal the end from iterator.next().
-
exception
SyntaxError
¶ Invalid syntax.
-
filename
¶ exception filename
-
lineno
¶ exception lineno
-
msg
¶ exception msg
-
offset
¶ exception offset
-
print_file_and_line
¶ exception print_file_and_line
-
text
¶ exception text
-
-
exception
SyntaxWarning
¶ Base class for warnings about dubious syntax.
-
exception
SystemError
¶ Internal error in the Python interpreter.
Please report this to the Python maintainer, along with the traceback, the Python version, and the hardware/OS platform and version.
-
exception
TabError
¶ Improper mixture of spaces and tabs.
-
exception
TypeError
¶ Inappropriate argument type.
-
exception
UnboundLocalError
¶ Local name referenced but not bound to a value.
-
exception
UnicodeDecodeError
¶ Unicode decoding error.
-
encoding
¶ exception encoding
-
end
¶ exception end
-
object
¶ exception object
-
reason
¶ exception reason
-
start
¶ exception start
-
-
exception
UnicodeEncodeError
¶ Unicode encoding error.
-
encoding
¶ exception encoding
-
end
¶ exception end
-
object
¶ exception object
-
reason
¶ exception reason
-
start
¶ exception start
-
-
exception
UnicodeError
¶ Unicode related error.
-
exception
UnicodeTranslateError
¶ Unicode translation error.
-
encoding
¶ exception encoding
-
end
¶ exception end
-
object
¶ exception object
-
reason
¶ exception reason
-
start
¶ exception start
-
-
exception
UnicodeWarning
¶ Base class for warnings about Unicode related problems, mostly related to conversion problems.
-
exception
UserWarning
¶ Base class for warnings generated by user code.
-
exception
ValueError
¶ Inappropriate argument value (of correct type).
-
exception
Warning
¶ Base class for warning categories.
-
exception
ZeroDivisionError
¶ Second argument to a division or modulo operation was zero.