summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2024-03-03 00:55:59 (GMT)
committerGitHub <noreply@github.com>2024-03-03 00:55:59 (GMT)
commit5b73ed4b6620fa52becfbe225c8ff8064962895b (patch)
tree10a598c0c6b13c890710a5be9081bfb2f2a8ff42
parent6aadabcfe667d1ad292ce04a9263b500ea74fb6e (diff)
downloadcpython-5b73ed4b6620fa52becfbe225c8ff8064962895b.zip
cpython-5b73ed4b6620fa52becfbe225c8ff8064962895b.tar.gz
cpython-5b73ed4b6620fa52becfbe225c8ff8064962895b.tar.bz2
[3.12] gh-72971: Clarify the special no-TypeError behavior for equality (GH-110729) (#116254)
(cherry picked from commit 67f742e03aacb6217c5bb496e31f96dbf31c6f86) Co-authored-by: Gouvernathor <44340603+Gouvernathor@users.noreply.github.com>
-rw-r--r--Doc/reference/datamodel.rst5
1 files changed, 4 insertions, 1 deletions
diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst
index c29c34f..e41697d 100644
--- a/Doc/reference/datamodel.rst
+++ b/Doc/reference/datamodel.rst
@@ -1805,12 +1805,15 @@ Basic customization
rather, :meth:`__lt__` and :meth:`__gt__` are each other's reflection,
:meth:`__le__` and :meth:`__ge__` are each other's reflection, and
:meth:`__eq__` and :meth:`__ne__` are their own reflection.
- If the operands are of different types, and right operand's type is
+ If the operands are of different types, and the right operand's type is
a direct or indirect subclass of the left operand's type,
the reflected method of the right operand has priority, otherwise
the left operand's method has priority. Virtual subclassing is
not considered.
+ When no appropriate method returns any value other than :data:`NotImplemented`, the
+ ``==`` and ``!=`` operators will fall back to ``is`` and ``is not``, respectively.
+
.. method:: object.__hash__(self)
.. index::