8000 gh-72971: Clarify the special no-TypeError behavior for equality by Gouvernathor · Pull Request #110729 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-72971: Clarify the special no-TypeError behavior for equality #110729

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 3, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Doc/reference/datamodel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1613,6 +1613,12 @@ Basic customization
the left operand's method has priority. Virtual subclassing is
not considered.

When no method returns any value other than NotImplemented, comparisons raise
a :exc:`TypeError`. However, the ``==`` and ``!=`` operators will not raise an
exception in that case, and will instead fall back to ``is`` and ``is not``,
respectively. That way, even though ``object().__eq__(object())`` returns
NotImplemented, ``object() == object()`` returns False.

.. method:: object.__hash__(self)

.. index::
Expand Down
0