exceptions
index
(built-in)
Module Docs

Python's standard exception class hierarchy.
 
Before Python 1.5, the standard exceptions were all simple string objects.
In Python 1.5, the standard exceptions were converted to classes organized
into a relatively flat hierarchy.  String-based standard exceptions were
optional, or used as a fallback if some problem occurred while importing
the exception module.  With Python 1.6, optional string-based standard
exceptions were removed (along with the -X command line flag).
 
The class exceptions were implemented in such a way as to be almost
completely backward compatible.  Some tricky uses of IOError could
potentially have broken, but by Python 1.6, all of these should have
been fixed.  As of Python 1.6, the class-based standard exceptions are
now implemented in C, and are guaranteed to exist in the Python
interpreter.
 
Here is a rundown of the class hierarchy.  The classes found here are
inserted into both the exceptions module and the `built-in' module.  It is
recommended that user defined class based exceptions be derived from the
`Exception' class, although this is currently not enforced.
 
Exception
 |
 +-- SystemExit
 +-- StopIteration
 +-- StandardError
 |    |
 |    +-- KeyboardInterrupt
 |    +-- ImportError
 |    +-- EnvironmentError
 |    |    |
 |    |    +-- IOError
 |    |    +-- OSError
 |    |         |
 |    |         +-- WindowsError
 |    |         +-- VMSError
 |    |
 |    +-- EOFError
 |    +-- RuntimeError
 |    |    |
 |    |    +-- NotImplementedError
 |    |
 |    +-- NameError
 |    |    |
 |    |    +-- UnboundLocalError
 |    |
 |    +-- AttributeError
 |    +-- SyntaxError
 |    |    |
 |    |    +-- IndentationError
 |    |         |
 |    |         +-- TabError
 |    |
 |    +-- TypeError
 |    +-- AssertionError
 |    +-- LookupError
 |    |    |
 |    |    +-- IndexError
 |    |    +-- KeyError
 |    |
 |    +-- ArithmeticError
 |    |    |
 |    |    +-- OverflowError
 |    |    +-- ZeroDivisionError
 |    |    +-- FloatingPointError
 |    |
 |    +-- ValueError
 |    |    |
 |    |    +-- UnicodeError
 |    |        |
 |    |        +-- UnicodeEncodeError
 |    |        +-- UnicodeDecodeError
 |    |        +-- UnicodeTranslateError
 |    |
 |    +-- ReferenceError
 |    +-- SystemError
 |    +-- MemoryError
 |
 +---Warning
      |
      +-- UserWarning
      +-- DeprecationWarning
      +-- PendingDeprecationWarning
      +-- SyntaxWarning
      +-- OverflowWarning
      +-- RuntimeWarning
      +-- FutureWarning

 
Classes
       
Exception
StandardError
ArithmeticError
FloatingPointError
OverflowError
ZeroDivisionError
AssertionError
AttributeError
EOFError
EnvironmentError
IOError
OSError
ImportError
KeyboardInterrupt
LookupError
IndexError
KeyError
MemoryError
NameError
UnboundLocalError
ReferenceError
RuntimeError
NotImplementedError
SyntaxError
IndentationError
TabError
SystemError
TypeError
ValueError
UnicodeError
UnicodeDecodeError
UnicodeEncodeError
UnicodeTranslateError
StopIteration
SystemExit
Warning
DeprecationWarning
FutureWarning
OverflowWarning
PendingDeprecationWarning
RuntimeWarning
SyntaxWarning
UserWarning

 
class ArithmeticError(StandardError)
    Base class for arithmetic errors.
 
 
Method resolution order:
ArithmeticError
StandardError
Exception

Methods inherited from Exception:
__getitem__(...)
__init__(...)
__str__(...)

 
class AssertionError(StandardError)
    Assertion failed.
 
 
Method resolution order:
AssertionError
StandardError
Exception

Methods inherited from Exception:
__getitem__(...)
__init__(...)
__str__(...)

 
class AttributeError(StandardError)
    Attribute not found.
 
 
Method resolution order:
AttributeError
StandardError
Exception

Methods inherited from Exception:
__getitem__(...)
__init__(...)
__str__(...)

 
class DeprecationWarning(Warning)
    Base class for warnings about deprecated features.
 
 
Method resolution order:
DeprecationWarning
Warning
Exception

Methods inherited from Exception:
__getitem__(...)
__init__(...)
__str__(...)

 
class EOFError(StandardError)
    Read beyond end of file.
 
 
Method resolution order:
EOFError
StandardError
Exception

Methods inherited from Exception:
__getitem__(...)
__init__(...)
__str__(...)

 
class EnvironmentError(StandardError)
    Base class for I/O related errors.
 
 
Method resolution order:
EnvironmentError
StandardError
Exception

Methods defined here:
__init__(...)
__str__(...)

Methods inherited from Exception:
__getitem__(...)

 
class Exception
    Common base class for all exceptions.
 
  Methods defined here:
__getitem__(...)
__init__(...)
__str__(...)

 
class FloatingPointError(ArithmeticError)
    Floating point operation failed.
 
 
Method resolution order:
FloatingPointError
ArithmeticError
StandardError
Exception

Methods inherited from Exception:
__getitem__(...)
__init__(...)
__str__(...)

 
class FutureWarning(Warning)
    Base class for warnings about constructs that will change semantically in the future.
 
 
Method resolution order:
FutureWarning
Warning
Exception

Methods inherited from Exception:
__getitem__(...)
__init__(...)
__str__(...)

 
class IOError(EnvironmentError)
    I/O operation failed.
 
 
Method resolution order:
IOError
EnvironmentError
StandardError
Exception

Methods inherited from EnvironmentError:
__init__(...)
__str__(...)

Methods inherited from Exception:
__getitem__(...)

 
class ImportError(StandardError)
    Import can't find module, or can't find name in module.
 
 
Method resolution order:
ImportError
StandardError
Exception

Methods inherited from Exception:
__getitem__(...)
__init__(...)
__str__(...)

 
class IndentationError(SyntaxError)
    Improper indentation.
 
 
Method resolution order:
IndentationError
SyntaxError
StandardError
Exception

Methods inherited from SyntaxError:
__init__(...)
__str__(...)

Data and other attributes inherited from SyntaxError:
filename = None
lineno = None
msg = ''
offset = None
print_file_and_line = None
text = None

Methods inherited from Exception:
__getitem__(...)

 
class IndexError(LookupError)
    Sequence index out of range.
 
 
Method resolution order:
IndexError
LookupError
StandardError
Exception

Methods inherited from Exception:
__getitem__(...)
__init__(...)
__str__(...)

 
class KeyError(LookupError)
    Mapping key not found.
 
 
Method resolution order:
KeyError
LookupError
StandardError
Exception

Methods defined here:
__str__(...)

Methods inherited from Exception:
__getitem__(...)
__init__(...)

 
class KeyboardInterrupt(StandardError)
    Program interrupted by user.
 
 
Method resolution order:
KeyboardInterrupt
StandardError
Exception

Methods inherited from Exception:
__getitem__(...)
__init__(...)
__str__(...)

 
class LookupError(StandardError)
    Base class for lookup errors.
 
 
Method resolution order:
LookupError
StandardError
Exception

Methods inherited from Exception:
__getitem__(...)
__init__(...)
__str__(...)

 
class MemoryError(StandardError)
    Out of memory.
 
 
Method resolution order:
MemoryError
StandardError
Exception

Methods inherited from Exception:
__getitem__(...)
__init__(...)
__str__(...)

 
class NameError(StandardError)
    Name not found globally.
 
 
Method resolution order:
NameError
StandardError
Exception

Methods inherited from Exception:
__getitem__(...)
__init__(...)
__str__(...)

 
class NotImplementedError(RuntimeError)
    Method or function hasn't been implemented yet.
 
 
Method resolution order:
NotImplementedError
RuntimeError
StandardError
Exception

Methods inherited from Exception:
__getitem__(...)
__init__(...)
__str__(...)

 
class OSError(EnvironmentError)
    OS system call failed.
 
 
Method resolution order:
OSError
EnvironmentError
StandardError
Exception

Methods inherited from EnvironmentError:
__init__(...)
__str__(...)

Methods inherited from Exception:
__getitem__(...)

 
class OverflowError(ArithmeticError)
    Result too large to be represented.
 
 
Method resolution order:
OverflowError
ArithmeticError
StandardError
Exception

Methods inherited from Exception:
__getitem__(...)
__init__(...)
__str__(...)

 
class OverflowWarning(Warning)
    Base class for warnings about numeric overflow.  Won't exist in Python 2.5.
 
 
Method resolution order:
OverflowWarning
Warning
Exception

Methods inherited from Exception:
__getitem__(...)
__init__(...)
__str__(...)

 
class PendingDeprecationWarning(Warning)
    Base class for warnings about features which will be deprecated in the future.
 
 
Method resolution order:
PendingDeprecationWarning
Warning
Exception

Methods inherited from Exception:
__getitem__(...)
__init__(...)
__str__(...)

 
class ReferenceError(StandardError)
    Weak ref proxy used after referent went away.
 
 
Method resolution order:
ReferenceError
StandardError
Exception

Methods inherited from Exception:
__getitem__(...)
__init__(...)
__str__(...)

 
class RuntimeError(StandardError)
    Unspecified run-time error.
 
 
Method resolution order:
RuntimeError
StandardError
Exception

Methods inherited from Exception:
__getitem__(...)
__init__(...)
__str__(...)

 
class RuntimeWarning(Warning)
    Base class for warnings about dubious runtime behavior.
 
 
Method resolution order:
RuntimeWarning
Warning
Exception

Methods inherited from Exception:
__getitem__(...)
__init__(...)
__str__(...)

 
class StandardError(Exception)
    Base class for all standard Python exceptions.
 
  Methods inherited from Exception:
__getitem__(...)
__init__(...)
__str__(...)

 
class StopIteration(Exception)
    Signal the end from iterator.next().
 
  Methods inherited from Exception:
__getitem__(...)
__init__(...)
__str__(...)

 
class SyntaxError(StandardError)
    Invalid syntax.
 
 
Method resolution order:
SyntaxError
StandardError
Exception

Methods defined here:
__init__(...)
__str__(...)

Data and other attributes defined here:
filename = None
lineno = None
msg = ''
offset = None
print_file_and_line = None
text = None

Methods inherited from Exception:
__getitem__(...)

 
class SyntaxWarning(Warning)
    Base class for warnings about dubious syntax.
 
 
Method resolution order:
SyntaxWarning
Warning
Exception

Methods inherited from Exception:
__getitem__(...)
__init__(...)
__str__(...)

 
class SystemError(StandardError)
    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.
 
 
Method resolution order:
SystemError
StandardError
Exception

Methods inherited from Exception:
__getitem__(...)
__init__(...)
__str__(...)

 
class SystemExit(Exception)
    Request to exit from the interpreter.
 
  Methods defined here:
__init__(...)

Methods inherited from Exception:
__getitem__(...)
__str__(...)

 
class TabError(IndentationError)
    Improper mixture of spaces and tabs.
 
 
Method resolution order:
TabError
IndentationError
SyntaxError
StandardError
Exception

Methods inherited from SyntaxError:
__init__(...)
__str__(...)

Data and other attributes inherited from SyntaxError:
filename = None
lineno = None
msg = ''
offset = None
print_file_and_line = None
text = None

Methods inherited from Exception:
__getitem__(...)

 
class TypeError(StandardError)
    Inappropriate argument type.
 
 
Method resolution order:
TypeError
StandardError
Exception

Methods inherited from Exception:
__getitem__(...)
__init__(...)
__str__(...)

 
class UnboundLocalError(NameError)
    Local name referenced but not bound to a value.
 
 
Method resolution order:
UnboundLocalError
NameError
StandardError
Exception

Methods inherited from Exception:
__getitem__(...)
__init__(...)
__str__(...)

 
class UnicodeDecodeError(UnicodeError)
    Unicode decoding error.
 
 
Method resolution order:
UnicodeDecodeError
UnicodeError
ValueError
StandardError
Exception

Methods defined here:
__init__(...)
__str__(...)

Methods inherited from Exception:
__getitem__(...)

 
class UnicodeEncodeError(UnicodeError)
    Unicode encoding error.
 
 
Method resolution order:
UnicodeEncodeError
UnicodeError
ValueError
StandardError
Exception

Methods defined here:
__init__(...)
__str__(...)

Methods inherited from Exception:
__getitem__(...)

 
class UnicodeError(ValueError)
    Unicode related error.
 
 
Method resolution order:
UnicodeError
ValueError
StandardError
Exception

Methods inherited from Exception:
__getitem__(...)
__init__(...)
__str__(...)

 
class UnicodeTranslateError(UnicodeError)
    Unicode translation error.
 
 
Method resolution order:
UnicodeTranslateError
UnicodeError
ValueError
StandardError
Exception

Methods defined here:
__init__(...)
__str__(...)

Methods inherited from Exception:
__getitem__(...)

 
class UserWarning(Warning)
    Base class for warnings generated by user code.
 
 
Method resolution order:
UserWarning
Warning
Exception

Methods inherited from Exception:
__getitem__(...)
__init__(...)
__str__(...)

 
class ValueError(StandardError)
    Inappropriate argument value (of correct type).
 
 
Method resolution order:
ValueError
StandardError
Exception

Methods inherited from Exception:
__getitem__(...)
__init__(...)
__str__(...)

 
class Warning(Exception)
    Base class for warning categories.
 
  Methods inherited from Exception:
__getitem__(...)
__init__(...)
__str__(...)

 
class ZeroDivisionError(ArithmeticError)
    Second argument to a division or modulo operation was zero.
 
 
Method resolution order:
ZeroDivisionError
ArithmeticError
StandardError
Exception

Methods inherited from Exception:
__getitem__(...)
__init__(...)
__str__(...)