Skip to content

Commit 5b73ed4

Browse files
[3.12] gh-72971: Clarify the special no-TypeError behavior for equality (GH-110729) (#116254)
(cherry picked from commit 67f742e) Co-authored-by: Gouvernathor <[email protected]>
1 parent 6aadabc commit 5b73ed4

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
@@ -1805,12 +1805,15 @@ Basic customization
18051805
rather, :meth:`__lt__` and :meth:`__gt__` are each other's reflection,
18061806
:meth:`__le__` and :meth:`__ge__` are each other's reflection, and
18071807
:meth:`__eq__` and :meth:`__ne__` are their own reflection.
1808-
If the operands are of different types, and right operand's type is
1808+
If the operands are of different types, and the right operand's type is
18091809
a direct or indirect subclass of the left operand's type,
18101810
the reflected method of the right operand has priority, otherwise
18111811
the left operand's method has priority. Virtual subclassing is
18121812
not considered.
18131813

1814+
When no appropriate method returns any value other than :data:`NotImplemented`, the
1815+
``==`` and ``!=`` operators will fall back to ``is`` and ``is not``, respectively.
1816+
18141817
.. method:: object.__hash__(self)
18151818

18161819
.. index::

0 commit comments

Comments
 (0)