summaryrefslogtreecommitdiffstats
path: root/Doc/reference
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2023-10-19 15:34:25 (GMT)
committerGitHub <noreply@github.com>2023-10-19 15:34:25 (GMT)
commit91a6e98e927ac529adeff57d33e87abcf448efec (patch)
treeef56163a734c39957a7df0e9f5e7130c0ea1c7e2 /Doc/reference
parentcdcab408a017fd8059921ffa0b4ee85be16e1e87 (diff)
downloadcpython-91a6e98e927ac529adeff57d33e87abcf448efec.zip
cpython-91a6e98e927ac529adeff57d33e87abcf448efec.tar.gz
cpython-91a6e98e927ac529adeff57d33e87abcf448efec.tar.bz2
[3.12] GH-101100: Fix reference warnings for ``__enter__`` and ``__exit__`` (GH-110112) (#111075)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Diffstat (limited to 'Doc/reference')
-rw-r--r--Doc/reference/compound_stmts.rst20
-rw-r--r--Doc/reference/datamodel.rst6
2 files changed, 13 insertions, 13 deletions
diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst
index 52308f3..8f64813 100644
--- a/Doc/reference/compound_stmts.rst
+++ b/Doc/reference/compound_stmts.rst
@@ -489,37 +489,37 @@ The execution of the :keyword:`with` statement with one "item" proceeds as follo
#. The context expression (the expression given in the
:token:`~python-grammar:with_item`) is evaluated to obtain a context manager.
-#. The context manager's :meth:`__enter__` is loaded for later use.
+#. The context manager's :meth:`~object.__enter__` is loaded for later use.
-#. The context manager's :meth:`__exit__` is loaded for later use.
+#. The context manager's :meth:`~object.__exit__` is loaded for later use.
-#. The context manager's :meth:`__enter__` method is invoked.
+#. The context manager's :meth:`~object.__enter__` method is invoked.
#. If a target was included in the :keyword:`with` statement, the return value
- from :meth:`__enter__` is assigned to it.
+ from :meth:`~object.__enter__` is assigned to it.
.. note::
- The :keyword:`with` statement guarantees that if the :meth:`__enter__`
- method returns without an error, then :meth:`__exit__` will always be
+ The :keyword:`with` statement guarantees that if the :meth:`~object.__enter__`
+ method returns without an error, then :meth:`~object.__exit__` will always be
called. Thus, if an error occurs during the assignment to the target list,
it will be treated the same as an error occurring within the suite would
be. See step 7 below.
#. The suite is executed.
-#. The context manager's :meth:`__exit__` method is invoked. If an exception
+#. The context manager's :meth:`~object.__exit__` method is invoked. If an exception
caused the suite to be exited, its type, value, and traceback are passed as
- arguments to :meth:`__exit__`. Otherwise, three :const:`None` arguments are
+ arguments to :meth:`~object.__exit__`. Otherwise, three :const:`None` arguments are
supplied.
If the suite was exited due to an exception, and the return value from the
- :meth:`__exit__` method was false, the exception is reraised. If the return
+ :meth:`~object.__exit__` method was false, the exception is reraised. If the return
value was true, the exception is suppressed, and execution continues with the
statement following the :keyword:`with` statement.
If the suite was exited for any reason other than an exception, the return
- value from :meth:`__exit__` is ignored, and execution proceeds at the normal
+ value from :meth:`~object.__exit__` is ignored, and execution proceeds at the normal
location for the kind of exit that was taken.
The following code::
diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst
index 362ac75..b8ad4c7 100644
--- a/Doc/reference/datamodel.rst
+++ b/Doc/reference/datamodel.rst
@@ -2939,7 +2939,7 @@ For more information on context managers, see :ref:`typecontextmanager`.
(i.e., prevent it from being propagated), it should return a true value.
Otherwise, the exception will be processed normally upon exit from this method.
- Note that :meth:`__exit__` methods should not reraise the passed-in exception;
+ Note that :meth:`~object.__exit__` methods should not reraise the passed-in exception;
this is the caller's responsibility.
@@ -3257,12 +3257,12 @@ Asynchronous context managers can be used in an :keyword:`async with` statement.
.. method:: object.__aenter__(self)
- Semantically similar to :meth:`__enter__`, the only
+ Semantically similar to :meth:`~object.__enter__`, the only
difference being that it must return an *awaitable*.
.. method:: object.__aexit__(self, exc_type, exc_value, traceback)
- Semantically similar to :meth:`__exit__`, the only
+ Semantically similar to :meth:`~object.__exit__`, the only
difference being that it must return an *awaitable*.
An example of an asynchronous context manager class::