summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorWilliam Chargin <wchargin@gmail.com>2021-08-04 20:43:06 (GMT)
committerGitHub <noreply@github.com>2021-08-04 20:43:06 (GMT)
commit80f33f266b4ad5925a3e58ea3a54ae139a6b6f0e (patch)
treedc9e5ac29d5428c9e882d4b31613cbf0baa0f618 /Doc
parenta8dc4893d2b28827e82447326ea47759c161a722 (diff)
downloadcpython-80f33f266b4ad5925a3e58ea3a54ae139a6b6f0e.zip
cpython-80f33f266b4ad5925a3e58ea3a54ae139a6b6f0e.tar.gz
cpython-80f33f266b4ad5925a3e58ea3a54ae139a6b6f0e.tar.bz2
bpo-41706: Fix special method invocation docs to mention using type() (GH-22084)
Diffstat (limited to 'Doc')
-rw-r--r--Doc/reference/datamodel.rst7
1 files changed, 4 insertions, 3 deletions
diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst
index bb0b7e0..2c76e56 100644
--- a/Doc/reference/datamodel.rst
+++ b/Doc/reference/datamodel.rst
@@ -2439,7 +2439,7 @@ left undefined.
(``+``, ``-``, ``*``, ``@``, ``/``, ``//``, ``%``, :func:`divmod`,
:func:`pow`, ``**``, ``<<``, ``>>``, ``&``, ``^``, ``|``). For instance, to
evaluate the expression ``x + y``, where *x* is an instance of a class that
- has an :meth:`__add__` method, ``x.__add__(y)`` is called. The
+ has an :meth:`__add__` method, ``type(x).__add__(x, y)`` is called. The
:meth:`__divmod__` method should be the equivalent to using
:meth:`__floordiv__` and :meth:`__mod__`; it should not be related to
:meth:`__truediv__`. Note that :meth:`__pow__` should be defined to accept
@@ -2475,8 +2475,9 @@ left undefined.
(swapped) operands. These functions are only called if the left operand does
not support the corresponding operation [#]_ and the operands are of different
types. [#]_ For instance, to evaluate the expression ``x - y``, where *y* is
- an instance of a class that has an :meth:`__rsub__` method, ``y.__rsub__(x)``
- is called if ``x.__sub__(y)`` returns *NotImplemented*.
+ an instance of a class that has an :meth:`__rsub__` method,
+ ``type(y).__rsub__(y, x)`` is called if ``type(x).__sub__(x, y)`` returns
+ *NotImplemented*.
.. index:: builtin: pow