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 ~~~~~~~~~~~~~~~ .. code-block:: none `ArithmeticError` is the base class for those built-in exceptions that are raised for various arithmetic errors. AssertionError ~~~~~~~~~~~~~~ .. code-block:: none 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 ~~~~~~~~~~~~~~ .. code-block:: none An `AttributeError` occurs when the code contains something like `object.x` and `x` is not a method or attribute (variable) belonging to `object`. BaseException ~~~~~~~~~~~~~ .. code-block:: none `BaseException` is the base class for all built-in exceptions. It is not meant to be directly inherited by user-defined classes. BlockingIOError ~~~~~~~~~~~~~~~ .. code-block:: none 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 ~~~~~~~~~~~~~~~ .. code-block:: none 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 ~~~~~~~~~~~ .. code-block:: none 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 ~~~~~~~~~~~~~~~~~ .. code-block:: none 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 ~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none 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 ~~~~~~~~~~~~~~~ .. code-block:: none 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 ~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none 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 ~~~~~~~~~~~~~~~~~~~~ .. code-block:: none 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 ~~~~~~~~ .. code-block:: none An `EOFError` is raised when the `input()` function hits an end-of-file condition (EOF) without reading any data. EnvironmentError ~~~~~~~~~~~~~~~~ .. code-block:: none 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 ~~~~~~~~~ .. code-block:: none All built-in exceptions defined by Python are derived from `Exception`. All user-defined exceptions should also be derived from this class. FileExistsError ~~~~~~~~~~~~~~~ .. code-block:: none 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 ~~~~~~~~~~~~~~~~~ .. code-block:: none 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 ~~~~~~~~~~~~~~~~~~ .. code-block:: none 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 ~~~~~~~~~~~~~ .. code-block:: none 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 ~~~~~~~ .. code-block:: none 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 ~~~~~~~~~~~ .. code-block:: none 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 ~~~~~~~~~~~~~~~~ .. code-block:: none An `IndentationError` occurs when a given line of code is not indented (aligned vertically with other lines) as expected. IndexError ~~~~~~~~~~ .. code-block:: none 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 ~~~~~~~~~~~~~~~~ .. code-block:: none 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 ~~~~~~~~~~~~~~~~~ .. code-block:: none 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 ~~~~~~~~ .. code-block:: none A `KeyError` is raised when a value is not found as a key in a Python dict or in a similar object. KeyboardInterrupt ~~~~~~~~~~~~~~~~~ .. code-block:: none 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 ~~~~~~~~~~~ .. code-block:: none `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 ~~~~~~~~~~~ .. code-block:: none 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 ~~~~~~~~~~~~~~~~~~~ .. code-block:: none 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 ~~~~~~~~~ .. code-block:: none 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 ~~~~~~~~~~~~~~~~~~ .. code-block:: none 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 ~~~~~~~~~~~~~~~~~~~ .. code-block:: none 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 ~~~~~~~ .. code-block:: none 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 ~~~~~~~~~~~~~ .. code-block:: none An `OverflowError` is raised when the result of an arithmetic operation is too large to be handled by the computer's processor. PermissionError ~~~~~~~~~~~~~~~ .. code-block:: none 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 ~~~~~~~~~~~~~~~~~~ .. code-block:: none 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 ~~~~~~~~~~~~~~ .. code-block:: none 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 ~~~~~~~~~~~~~~ .. code-block:: none 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 ~~~~~~~~~~~~ .. code-block:: none 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 ~~~~~~~~~~~~~~~~~~ .. code-block:: none 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 ~~~~~~~~~~~~~ .. code-block:: none `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 ~~~~~~~~~~~ .. code-block:: none A `SyntaxError` occurs when Python cannot understand your code. SystemError ~~~~~~~~~~~ .. code-block:: none 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 ~~~~~~~~~~ .. code-block:: none 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 ~~~~~~~~ .. code-block:: none 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 ~~~~~~~~~~~~ .. code-block:: none 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 ~~~~~~~~~ .. code-block:: none 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 ~~~~~~~~~~~~~~~~~ .. code-block:: none 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 ~~~~~~~~~~~~~~~~~~ .. code-block:: none 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 ~~~~~~~~~~~~~~~~~~ .. code-block:: none 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 ~~~~~~~~~~~~ .. code-block:: none 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 ~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none 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 ~~~~~~~~~~ .. code-block:: none A `ValueError` indicates that a function or an operation received an argument of the right type, but an inappropriate value. WindowsError ~~~~~~~~~~~~ .. code-block:: none 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 ~~~~~~~~~~~~~~~~~ .. code-block:: none A `ZeroDivisionError` occurs when you are attempting to divide a value by zero either directly or by using some other mathematical operation. Warnings ---------- BytesWarning ~~~~~~~~~~~~ .. code-block:: none `BytesWarning` is the base category for warnings related to bytes and bytearray. DeprecationWarning ~~~~~~~~~~~~~~~~~~ .. code-block:: none `DeprecationWarning` indicates that some feature will not be available in a future version. FutureWarning ~~~~~~~~~~~~~ .. code-block:: none `FutureWarning` is the base category for features that will likely be deprecated in future Python versions. ImportWarning ~~~~~~~~~~~~~ .. code-block:: none 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 ~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none 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 ~~~~~~~~~~~~~~~ .. code-block:: none 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 ~~~~~~~~~~~~~~ .. code-block:: none `RuntimeWarning` often indicates some not recommended runtime features. SyntaxWarning ~~~~~~~~~~~~~ .. code-block:: none `SyntaxWarning` often indicates that your code will likely not give the result you expect. UnicodeWarning ~~~~~~~~~~~~~~ .. code-block:: none `UnicodeWarning` is the base category for warnings related to unicode. UserWarning ~~~~~~~~~~~ .. code-block:: none `UserWarning` is the default class for `warnings.warn()`. Warning ~~~~~~~ .. code-block:: none `Warning` is the base class of all warning category classes.