This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: tp_richcompare documentation wrong and incomplete
Type: Stage:
Components: Documentation Versions: Python 2.4
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: barry, fdrake, georg.brandl
Priority: high Keywords:

Created on 2005-06-13 19:10 by barry, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg60758 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2005-06-13 19:10
tp_richcompare slot as documented here:

is incorrect.  It states: "The signature is the same as
for PyObject_RichCompare(). The function should return
1 if the requested comparison returns true, 0 if it
returns false. It should return -1 and set an exception
condition when an error occurred during the comparison"

However PyObject_RichCompare() actually returns a
PyObject* not an int.  The documentation at this
location really should spell out the full specification
for the richcomparefunc.

In addition, it's not exactly clear how to implement
unordered comparisons (ones where == and != work, but
<, >, <=, >= don't).  You cannot return
Py_NotImplemented because richcomp always falls back to
pointer comparison unless PyInstance_Check() is true. 
For extension types, this won't be the case and the
right thing to do is actually raise the exception in
the richcomp function.  This needs to be documented too.
msg61355 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-01-20 19:48
Fixed in r60146.
Date User Action Args
2022-04-11 14:56:11adminsetgithub: 42081
2008-01-20 19:48:47georg.brandlsetstatus: open -> closed
assignee: fdrake -> georg.brandl
resolution: fixed
messages: + msg61355
nosy: + georg.brandl
2005-06-13 19:10:29bwarsaw.historiccreate