diff options
author | Gouvernathor <44340603+Gouvernathor@users.noreply.github.com> | 2024-03-03 00:45:48 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-03 00:45:48 (GMT) |
commit | 67f742e03aacb6217c5bb496e31f96dbf31c6f86 (patch) | |
tree | 9f13f084122e93ead7994ff83a6886bc4e82d46e | |
parent | d1fd0606591e1258eb083d003aed85c61ef2b6cf (diff) | |
download | cpython-67f742e03aacb6217c5bb496e31f96dbf31c6f86.zip cpython-67f742e03aacb6217c5bb496e31f96dbf31c6f86.tar.gz cpython-67f742e03aacb6217c5bb496e31f96dbf31c6f86.tar.bz2 |
gh-72971: Clarify the special no-TypeError behavior for equality (#110729)
-rw-r--r-- | Doc/reference/datamodel.rst | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index 82106a4..75b656f 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -1812,12 +1812,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:: |