summaryrefslogtreecommitdiff
path: root/Doc/library/exceptions.rst
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/library/exceptions.rst')
-rw-r--r--Doc/library/exceptions.rst38
1 files changed, 35 insertions, 3 deletions
diff --git a/Doc/library/exceptions.rst b/Doc/library/exceptions.rst
index 271a5c8219..0a422b238d 100644
--- a/Doc/library/exceptions.rst
+++ b/Doc/library/exceptions.rst
@@ -162,7 +162,8 @@ The following exceptions are the exceptions that are usually raised.
.. exception:: GeneratorExit
- Raised when a :term:`generator`\'s :meth:`close` method is called. It
+ Raised when a :term:`generator` or :term:`coroutine` is closed;
+ see :meth:`generator.close` and :meth:`coroutine.close`. It
directly inherits from :exc:`BaseException` instead of :exc:`Exception` since
it is technically not an error.
@@ -281,6 +282,16 @@ The following exceptions are the exceptions that are usually raised.
handling in C, most floating point operations are not checked.
+.. exception:: RecursionError
+
+ This exception is derived from :exc:`RuntimeError`. It is raised when the
+ interpreter detects that the maximum recursion depth (see
+ :func:`sys.getrecursionlimit`) is exceeded.
+
+ .. versionadded:: 3.5
+ Previously, a plain :exc:`RuntimeError` was raised.
+
+
.. exception:: ReferenceError
This exception is raised when a weak reference proxy, created by the
@@ -306,14 +317,30 @@ The following exceptions are the exceptions that are usually raised.
given as an argument when constructing the exception, and defaults
to :const:`None`.
- When a generator function returns, a new :exc:`StopIteration` instance is
+ When a :term:`generator` or :term:`coroutine` function
+ returns, a new :exc:`StopIteration` instance is
raised, and the value returned by the function is used as the
:attr:`value` parameter to the constructor of the exception.
+ If a generator function defined in the presence of a ``from __future__
+ import generator_stop`` directive raises :exc:`StopIteration`, it will be
+ converted into a :exc:`RuntimeError` (retaining the :exc:`StopIteration`
+ as the new exception's cause).
+
.. versionchanged:: 3.3
Added ``value`` attribute and the ability for generator functions to
use it to return a value.
+ .. versionchanged:: 3.5
+ Introduced the RuntimeError transformation.
+
+.. exception:: StopAsyncIteration
+
+ Must be raised by :meth:`__anext__` method of an
+ :term:`asynchronous iterator` object to stop the iteration.
+
+ .. versionadded:: 3.5
+
.. exception:: SyntaxError
Raised when the parser encounters a syntax error. This may occur in an
@@ -536,7 +563,12 @@ depending on the system error code.
.. exception:: InterruptedError
Raised when a system call is interrupted by an incoming signal.
- Corresponds to :c:data:`errno` ``EINTR``.
+ Corresponds to :c:data:`errno` :py:data:`~errno.EINTR`.
+
+ .. versionchanged:: 3.5
+ Python now retries system calls when a syscall is interrupted by a
+ signal, except if the signal handler raises an exception (see :pep:`475`
+ for the rationale), instead of raising :exc:`InterruptedError`.
.. exception:: IsADirectoryError