Skip to content

bpo-29986: Delete tip to raise TypeError from tp_richcompare. #987

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

Closed
wants to merge 3 commits into from
Closed
Changes from all 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: 0 additions & 6 deletions Doc/c-api/typeobj.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1311,12 +1311,6 @@ and :c:type:`PyType_Type` effectively act as defaults.)
``Py_NotImplemented``, if another error occurred it must return *NULL* and
set an exception condition.

.. note::

If you want to implement a type for which only a limited set of
comparisons makes sense (e.g. ``==`` and ``!=``, but not ``<`` and
friends), directly raise :exc:`TypeError` in the rich comparison function.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of removing this note, maybe you should change it say return NotImplemented instead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately that clashes with guidance provided on the issue. :) Maybe this can get hashed out there?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately that clashes with guidance provided on the issue

The important thing is that the bad advice (raise TypeError) is removed. The consensus is to return NotImplemented in this case. How explicit you want to make that in the docs is bikeshedding territory.

In other words: I'm totally fine with just removing that paragraph.


The following constants are defined to be used as the third argument for
:c:member:`~PyTypeObject.tp_richcompare` and for :c:func:`PyObject_RichCompare`:

Expand Down