Warning

Most of the documentation was written prior to version 0.5 and needs to be updated. This work has now started for version 0.7 and we aim to have it completed before version 0.8 is available.

Generic information about various exceptions

Note

The content of this page is generated by running what.py located in the tests/ directory. This needs to be done explicitly, independently of updating the documentation using Sphinx.

This file contains the generic information provided by Friendly-traceback about built-in exceptions. By “generic information” we mean the information provided using what() in a friendly console.

Some exceptions will never be seen by users of Friendly-traceback.

For example, SystemExit and KeyboardInterrupt are never intercepted by Friendly-traceback. Furthermore, exceptions such as GeneratorExit, FloatingPointError, and StopAsyncIteration, would likely never be seen.

FloatingPointError is actually not used by Python.

BaseException, Exception, and ArithmeticError are base classes which are also not normally seen: some derived classes are normally used instead.

Information compiled using Friendly version: 0.7.53, Python version: 3.6.8

Exceptions

ArithmeticError

`ArithmeticError` is the base class for those built-in exceptions
that are raised for various arithmetic errors.

AssertionError

In Python, the keyword `assert` is used in statements of the form
`assert condition`, to confirm that `condition` is not `False`,
nor equivalent to `False` such as an empty list, etc.
If `condition` is `False` or equivalent, an `AssertionError` is raised.

AttributeError

An `AttributeError` occurs when the code contains something like
    `object.x`
and `x` is not a method or attribute (variable) belonging to `object`.

BaseException

`BaseException` is the base class for all built-in exceptions.
It is not meant to be directly inherited by user-defined classes.

BlockingIOError

An exception of type `BlockingIOError` is a subclass of `OSError`.
Nothing more specific is known about `BlockingIOError`.
An `OSError` exception is usually raised by the Operating System
to indicate that an operation is not allowed or that
a resource is not available.

BrokenPipeError

An exception of type `BrokenPipeError` is a subclass of `OSError`.
Nothing more specific is known about `BrokenPipeError`.
The inheritance is as follows:
    BrokenPipeError -> ConnectionError -> OSError
An `OSError` exception is usually raised by the Operating System
to indicate that an operation is not allowed or that
a resource is not available.

BufferError

An exception of type `BufferError` is a subclass of `Exception`.
Nothing more specific is known about `BufferError`.
All built-in exceptions defined by Python are derived from `Exception`.
All user-defined exceptions should also be derived from this class.

ChildProcessError

An exception of type `ChildProcessError` is a subclass of `OSError`.
Nothing more specific is known about `ChildProcessError`.
An `OSError` exception is usually raised by the Operating System
to indicate that an operation is not allowed or that
a resource is not available.

ConnectionAbortedError

An exception of type `ConnectionAbortedError` is a subclass of `OSError`.
Nothing more specific is known about `ConnectionAbortedError`.
The inheritance is as follows:
    ConnectionAbortedError -> ConnectionError -> OSError
An `OSError` exception is usually raised by the Operating System
to indicate that an operation is not allowed or that
a resource is not available.

ConnectionError

An exception of type `ConnectionError` is a subclass of `OSError`.
Nothing more specific is known about `ConnectionError`.
An `OSError` exception is usually raised by the Operating System
to indicate that an operation is not allowed or that
a resource is not available.

ConnectionRefusedError

An exception of type `ConnectionRefusedError` is a subclass of `OSError`.
Nothing more specific is known about `ConnectionRefusedError`.
The inheritance is as follows:
    ConnectionRefusedError -> ConnectionError -> OSError
An `OSError` exception is usually raised by the Operating System
to indicate that an operation is not allowed or that
a resource is not available.

ConnectionResetError

An exception of type `ConnectionResetError` is a subclass of `OSError`.
Nothing more specific is known about `ConnectionResetError`.
The inheritance is as follows:
    ConnectionResetError -> ConnectionError -> OSError
An `OSError` exception is usually raised by the Operating System
to indicate that an operation is not allowed or that
a resource is not available.

EOFError

An `EOFError` is raised when the `input()` function hits
an end-of-file condition (EOF) without reading any data.

EnvironmentError

An `OSError` exception is usually raised by the Operating System
to indicate that an operation is not allowed or that
a resource is not available.

Exception

All built-in exceptions defined by Python are derived from `Exception`.
All user-defined exceptions should also be derived from this class.

FileExistsError

An exception of type `FileExistsError` is a subclass of `OSError`.
Nothing more specific is known about `FileExistsError`.
An `OSError` exception is usually raised by the Operating System
to indicate that an operation is not allowed or that
a resource is not available.

FileNotFoundError

A `FileNotFoundError` exception indicates that you
are trying to open a file that cannot be found by Python.
This could be because you misspelled the name of the file.

FloatingPointError

An exception of type `FloatingPointError` is a subclass of `ArithmeticError`.
Nothing more specific is known about `FloatingPointError`.
`ArithmeticError` is the base class for those built-in exceptions
that are raised for various arithmetic errors.

GeneratorExit

An exception of type `GeneratorExit` is a subclass of `BaseException`.
Nothing more specific is known about `GeneratorExit`.
`BaseException` is the base class for all built-in exceptions.
It is not meant to be directly inherited by user-defined classes.

IOError

An `OSError` exception is usually raised by the Operating System
to indicate that an operation is not allowed or that
a resource is not available.

ImportError

An `ImportError` exception indicates that a certain object could not
be imported from a module or package. Most often, this is
because the name of the object is not spelled correctly.

IndentationError

An `IndentationError` occurs when a given line of code is
not indented (aligned vertically with other lines) as expected.

IndexError

An `IndexError` occurs when you try to get an item from a list,
a tuple, or a similar object (sequence), and use an index which
does not exist; typically, this happens because the index you give
is greater than the length of the sequence.

InterruptedError

An exception of type `InterruptedError` is a subclass of `OSError`.
Nothing more specific is known about `InterruptedError`.
An `OSError` exception is usually raised by the Operating System
to indicate that an operation is not allowed or that
a resource is not available.

IsADirectoryError

An exception of type `IsADirectoryError` is a subclass of `OSError`.
Nothing more specific is known about `IsADirectoryError`.
An `OSError` exception is usually raised by the Operating System
to indicate that an operation is not allowed or that
a resource is not available.

KeyError

A `KeyError` is raised when a value is not found as a
key in a Python dict or in a similar object.

KeyboardInterrupt

An exception of type `KeyboardInterrupt` is a subclass of `BaseException`.
Nothing more specific is known about `KeyboardInterrupt`.
`BaseException` is the base class for all built-in exceptions.
It is not meant to be directly inherited by user-defined classes.

LookupError

`LookupError` is the base class for the exceptions that are raised
when a key or index used on a mapping or sequence is invalid.
It can also be raised directly by codecs.lookup().

MemoryError

Like the name indicates, a `MemoryError` occurs when Python
runs out of memory. This can happen if you create an object
that is too big, like a list with too many items.

ModuleNotFoundError

A `ModuleNotFoundError` exception indicates that you
are trying to import a module that cannot be found by Python.
This could be because you misspelled the name of the module
or because it is not installed on your computer.

NameError

A `NameError` exception indicates that a variable or
function name is not known to Python.
Most often, this is because there is a spelling mistake.
However, sometimes it is because the name is used
before being defined or given a value.

NotADirectoryError

An exception of type `NotADirectoryError` is a subclass of `OSError`.
Nothing more specific is known about `NotADirectoryError`.
An `OSError` exception is usually raised by the Operating System
to indicate that an operation is not allowed or that
a resource is not available.

NotImplementedError

An exception of type `NotImplementedError` is a subclass of `RuntimeError`.
Nothing more specific is known about `NotImplementedError`.
A `RuntimeError` is raised when an error is detected that doesn't fall in any
of the more specific exception types defined by Python.

OSError

An `OSError` exception is usually raised by the Operating System
to indicate that an operation is not allowed or that
a resource is not available.

OverflowError

An `OverflowError` is raised when the result of an arithmetic operation
is too large to be handled by the computer's processor.

PermissionError

An exception of type `PermissionError` is a subclass of `OSError`.
Nothing more specific is known about `PermissionError`.
An `OSError` exception is usually raised by the Operating System
to indicate that an operation is not allowed or that
a resource is not available.

ProcessLookupError

An exception of type `ProcessLookupError` is a subclass of `OSError`.
Nothing more specific is known about `ProcessLookupError`.
An `OSError` exception is usually raised by the Operating System
to indicate that an operation is not allowed or that
a resource is not available.

RecursionError

A `RecursionError` is raised when a function calls itself,
directly or indirectly, too many times.
It almost always indicates that you made an error in your code
and that your program would never stop.

ReferenceError

An exception of type `ReferenceError` is a subclass of `Exception`.
Nothing more specific is known about `ReferenceError`.
All built-in exceptions defined by Python are derived from `Exception`.
All user-defined exceptions should also be derived from this class.

RuntimeError

A `RuntimeError` is raised when an error is detected that doesn't fall in any
of the more specific exception types defined by Python.

StopAsyncIteration

An exception of type `StopAsyncIteration` is a subclass of `Exception`.
Nothing more specific is known about `StopAsyncIteration`.
All built-in exceptions defined by Python are derived from `Exception`.
All user-defined exceptions should also be derived from this class.

StopIteration

`StopIteration` is raised to indicate that an iterator has no more
item to provide when its `__next__` method is called by
the `next()` builtin function.

SyntaxError

A `SyntaxError` occurs when Python cannot understand your code.

SystemError

An exception of type `SystemError` is a subclass of `Exception`.
Nothing more specific is known about `SystemError`.
All built-in exceptions defined by Python are derived from `Exception`.
All user-defined exceptions should also be derived from this class.

SystemExit

An exception of type `SystemExit` is a subclass of `BaseException`.
Nothing more specific is known about `SystemExit`.
`BaseException` is the base class for all built-in exceptions.
It is not meant to be directly inherited by user-defined classes.

TabError

A `TabError` indicates that you have used both spaces
and tab characters to indent your code.
This is not allowed in Python.
Indenting your code means to have block of codes aligned vertically
by inserting either spaces or tab characters at the beginning of lines.
Python's recommendation is to always use spaces to indent your code.

TimeoutError

An exception of type `TimeoutError` is a subclass of `OSError`.
Nothing more specific is known about `TimeoutError`.
An `OSError` exception is usually raised by the Operating System
to indicate that an operation is not allowed or that
a resource is not available.

TypeError

A `TypeError` is usually caused by trying
to combine two incompatible types of objects,
by calling a function with the wrong type of object,
or by trying to do an operation not allowed on a given type of object.

UnboundLocalError

In Python, variables that are used inside a function are known as
local variables. Before they are used, they must be assigned a value.
A variable that is used before it is assigned a value is assumed to
be defined outside that function; it is known as a `global`
(or sometimes `nonlocal`) variable. You cannot assign a value to such
a global variable inside a function without first indicating to
Python that this is a global variable, otherwise you will see
an `UnboundLocalError`.

UnicodeDecodeError

An exception of type `UnicodeDecodeError` is a subclass of `ValueError`.
Nothing more specific is known about `UnicodeDecodeError`.
The inheritance is as follows:
    UnicodeDecodeError -> UnicodeError -> ValueError
A `ValueError` indicates that a function or an operation
received an argument of the right type, but an inappropriate value.

UnicodeEncodeError

An exception of type `UnicodeEncodeError` is a subclass of `ValueError`.
Nothing more specific is known about `UnicodeEncodeError`.
The inheritance is as follows:
    UnicodeEncodeError -> UnicodeError -> ValueError
A `ValueError` indicates that a function or an operation
received an argument of the right type, but an inappropriate value.

UnicodeError

An exception of type `UnicodeError` is a subclass of `ValueError`.
Nothing more specific is known about `UnicodeError`.
A `ValueError` indicates that a function or an operation
received an argument of the right type, but an inappropriate value.

UnicodeTranslateError

An exception of type `UnicodeTranslateError` is a subclass of `ValueError`.
Nothing more specific is known about `UnicodeTranslateError`.
The inheritance is as follows:
    UnicodeTranslateError -> UnicodeError -> ValueError
A `ValueError` indicates that a function or an operation
received an argument of the right type, but an inappropriate value.

ValueError

A `ValueError` indicates that a function or an operation
received an argument of the right type, but an inappropriate value.

WindowsError

An `OSError` exception is usually raised by the Operating System
to indicate that an operation is not allowed or that
a resource is not available.

ZeroDivisionError

A `ZeroDivisionError` occurs when you are attempting to divide a value
by zero either directly or by using some other mathematical operation.

Warnings

BytesWarning

`BytesWarning` is the base category for warnings related to bytes and bytearray.

DeprecationWarning

`DeprecationWarning` indicates that some feature will not be available in a future version.

FutureWarning

`FutureWarning` is the base category for features that will likely be deprecated
in future Python versions.

ImportWarning

A warning of type `ImportWarning` is a subclass of `Warning`.
Nothing more specific is known about `ImportWarning`.
`Warning` is the base class of all warning category classes.

PendingDeprecationWarning

A warning of type `PendingDeprecationWarning` is a subclass of `Warning`.
Nothing more specific is known about `PendingDeprecationWarning`.
`Warning` is the base class of all warning category classes.

ResourceWarning

A warning of type `ResourceWarning` is a subclass of `Warning`.
Nothing more specific is known about `ResourceWarning`.
`Warning` is the base class of all warning category classes.

RuntimeWarning

`RuntimeWarning` often indicates some not recommended runtime features.

SyntaxWarning

`SyntaxWarning` often indicates that your code will likely not give the result you expect.

UnicodeWarning

`UnicodeWarning` is the base category for warnings related to unicode.

UserWarning

`UserWarning` is the default class for `warnings.warn()`.

Warning

`Warning` is the base class of all warning category classes.