8000 gh-72971: Clarify the special no-TypeError behavior for equality (#11… · adorilson/cpython@05e9c0e · GitHub
[go: up one dir, main page]

Skip to content

Commit 05e9c0e

Browse files
Gouvernathoradorilson
authored andcommitted
pythongh-72971: Clarify the special no-TypeError behavior for equality (python#110729)
1 parent 5c4a04d commit 05e9c0e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Doc/reference/datamodel.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1817,12 +1817,15 @@ Basic customization
18171817
rather, :meth:`__lt__` and :meth:`__gt__` are each other's reflection,
18181818
:meth:`__le__` and :meth:`__ge__` are each other's reflection, and
18191819
:meth:`__eq__` and :meth:`__ne__` are their own reflection.
1820-
If the operands are of different types, and right operand's type is
1820+
If the operands are of different types, and the right operand's type is
18211821
a direct or indirect subclass of the left operand's type,
18221822
the reflected method of the right operand has priority, otherwise
18231823
the left operand's method has priority. Virtual subclassing is
18241824
not considered.
18251825

1826+
When no appropriate method returns any value other than :data:`NotImplemented`, the
1827+
``==`` and ``!=`` operators will fall back to ``is`` and ``is not``, respectively.
1828+
18261829
.. method:: object.__hash__(self)
18271830

18281831
.. index::

0 commit comments

Comments
 (0)
0