Skip to content

Commit 31ceccb

Browse files
bpo-41584: clarify when the reflected method of a binary arithemtic operator is called (GH-22505)
(cherry picked from commit d02d824) Co-authored-by: Brett Cannon <[email protected]>
1 parent 7e941fa commit 31ceccb

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

Doc/reference/datamodel.rst

+8-7
Original file line numberDiff line numberDiff line change
@@ -2371,10 +2371,11 @@ left undefined.
23712371

23722372
.. note::
23732373

2374-
If the right operand's type is a subclass of the left operand's type and that
2375-
subclass provides the reflected method for the operation, this method will be
2376-
called before the left operand's non-reflected method. This behavior allows
2377-
subclasses to override their ancestors' operations.
2374+
If the right operand's type is a subclass of the left operand's type and
2375+
that subclass provides a different implementation of the reflected method
2376+
for the operation, this method will be called before the left operand's
2377+
non-reflected method. This behavior allows subclasses to override their
2378+
ancestors' operations.
23782379

23792380

23802381
.. method:: object.__iadd__(self, other)
@@ -2773,6 +2774,6 @@ An example of an asynchronous context manager class::
27732774
method—that will instead have the opposite effect of explicitly
27742775
*blocking* such fallback.
27752776
2776-
.. [#] For operands of the same type, it is assumed that if the non-reflected method
2777-
(such as :meth:`__add__`) fails the operation is not supported, which is why the
2778-
reflected method is not called.
2777+
.. [#] For operands of the same type, it is assumed that if the non-reflected
2778+
method -- such as :meth:`__add__` -- fails then the overall operation is not
2779+
supported, which is why the reflected method is not called.

0 commit comments

Comments
 (0)