https://github.com/python/cpython/commit/82e7692ca649993718e1988e5959d06a0c16f029 commit: 82e7692ca649993718e1988e5959d06a0c16f029 branch: 3.11 author: Miss Islington (bot) <[email protected]> committer: erlend-aasland <[email protected]> date: 2024-03-03T01:56:19+01:00 summary:
[3.11] gh-72971: Clarify the special no-TypeError behavior for equality (GH-110729) (#116255) (cherry picked from commit 67f742e03aacb6217c5bb496e31f96dbf31c6f86) Co-authored-by: Gouvernathor <[email protected]> files: M Doc/reference/datamodel.rst diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index c1f4230c3dbcbb..d7b6e2bb1d2808 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -1788,12 +1788,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:: _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
