Skip to content

Commit 694874b

Browse files
miss-islingtonGouvernathorCAM-GerlachJelleZijlstra
authored
[3.12] gh-104219: Document that idunders can return NotImplemented (GH-104220) (#116210)
(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 d341098 commit 694874b

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
@@ -3037,10 +3037,12 @@ left undefined.
30373037
(``+=``, ``-=``, ``*=``, ``@=``, ``/=``, ``//=``, ``%=``, ``**=``, ``<<=``,
30383038
``>>=``, ``&=``, ``^=``, ``|=``). These methods should attempt to do the
30393039
operation in-place (modifying *self*) and return the result (which could be,
3040-
but does not have to be, *self*). If a specific method is not defined, the
3040+
but does not have to be, *self*). If a specific method is not defined, or if
3041+
that method returns :data:`NotImplemented`, the
30413042
augmented assignment falls back to the normal methods. For instance, if *x*
30423043
is an instance of a class with an :meth:`__iadd__` method, ``x += y`` is
3043-
equivalent to ``x = x.__iadd__(y)`` . Otherwise, ``x.__add__(y)`` and
3044+
equivalent to ``x = x.__iadd__(y)`` . If :meth:`__iadd__` does not exist, or if ``x.__iadd__(y)``
3045+
returns :data:`!NotImplemented`, ``x.__add__(y)`` and
30443046
``y.__radd__(x)`` are considered, as with the evaluation of ``x + y``. In
30453047
certain situations, augmented assignment can result in unexpected errors (see
30463048
:ref:`faq-augmented-assignment-tuple-error`), but this behavior is in fact

0 commit comments

Comments
 (0)