Skip to content

Commit 9eb7ed7

Browse files
miss-islingtonGouvernathorCAM-GerlachJelleZijlstra
authored
[3.11] gh-104219: Document that idunders can return NotImplemented (GH-104220) (#116211)
(cherry picked from commit 2713c2a) Co-authored-by: Gouvernathor <[email protected]> Co-authored-by: C.A.M. Gerlach <[email protected]> Co-authored-by: Jelle Zijlstra <[email protected]>
1 parent 677356b commit 9eb7ed7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Doc/reference/datamodel.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3016,10 +3016,12 @@ left undefined.
30163016
(``+=``, ``-=``, ``*=``, ``@=``, ``/=``, ``//=``, ``%=``, ``**=``, ``<<=``,
30173017
``>>=``, ``&=``, ``^=``, ``|=``). These methods should attempt to do the
30183018
operation in-place (modifying *self*) and return the result (which could be,
3019-
but does not have to be, *self*). If a specific method is not defined, the
3019+
but does not have to be, *self*). If a specific method is not defined, or if
3020+
that method returns :data:`NotImplemented`, the
30203021
augmented assignment falls back to the normal methods. For instance, if *x*
30213022
is an instance of a class with an :meth:`__iadd__` method, ``x += y`` is
3022-
equivalent to ``x = x.__iadd__(y)`` . Otherwise, ``x.__add__(y)`` and
3023+
equivalent to ``x = x.__iadd__(y)`` . If :meth:`__iadd__` does not exist, or if ``x.__iadd__(y)``
3024+
returns :data:`!NotImplemented`, ``x.__add__(y)`` and
30233025
``y.__radd__(x)`` are considered, as with the evaluation of ``x + y``. In
30243026
certain situations, augmented assignment can result in unexpected errors (see
30253027
:ref:`faq-augmented-assignment-tuple-error`), but this behavior is in fact

0 commit comments

Comments
 (0)