Built-in Exceptions — Python 3.9.25 documentation

docs.python.org

Tin mới

Text Processing Services

Python documentation for the current stable release

In Python, all exceptions must be instances of a class that derives from BaseException. In a try statement with an except clause that mentions a particular class, that clause also handles any exception classes derived fr

Python Module Index

3.9.25 Documentation

The Python Standard Library

Exception context¶

In Python, all exceptions must be instances of a class that derives from BaseException. In a try statement with an except clause that mentions a particular class, that clause also handles any exception classes derived fr

User-defined Exceptions

In Python, all exceptions must be instances of a class that derives from BaseException. In a try statement with an except clause that mentions a particular class, that clause also handles any exception classes derived fr

Exception context¶

When raising a new exception while another exception is already being handled, the new exception’s __context__ attribute is automatically set to the handled exception. An exception may be handled when an except or finall

Exception context¶

When raising a new exception while another exception is already being handled, the new exception’s __context__ attribute is automatically set to the handled exception. An exception may be handled when an except or finall

Attribute references

Raised when an attribute reference (see Attribute references) or assignment fails. (When an object does not support attribute references or attribute assignments at all, TypeError is raised.)

io.IOBase.readline()

Raised when the input() function hits an end-of-file condition (EOF) without reading any data. (N.B.: the io.IOBase.read() and io.IOBase.readline() methods return an empty string when they hit EOF.)

Note on Signal Handlers and Exceptions

Catching a KeyboardInterrupt requires special consideration. Because it can be raised at unpredictable points, it may, in some circumstances, leave the running program in an inconsistent state. It is generally best to al

sys.getrecursionlimit()

This exception is derived from RuntimeError. It is raised when the interpreter detects that the maximum recursion depth (see sys.getrecursionlimit()) is exceeded.

weakref: Support for weak references and weak dictionaries.

This exception is raised when a weak reference proxy, created by the weakref.proxy() function, is used to access an attribute of the referent after it has been garbage collected. For more information on weak references,

asynchronous iterator

Must be raised by __anext__() method of an asynchronous iterator object to stop the iteration.

errno.ECONNABORTED

A subclass of ConnectionError, raised when a connection attempt is aborted by the peer. Corresponds to errno ECONNABORTED.

Warning Categories

The following exceptions are used as warning categories; see the Warning Categories documentation for more details.

Python Development Mode

Base class for warnings about deprecated features when those warnings are intended for other Python developers.