[ python-Bugs-1219903 ] tp_richcompare documentation wrong and incomplete
SourceForge.net
noreply at sourceforge.net
Mon Jun 13 21:10:29 CEST 2005
Bugs item #1219903, was opened at 2005-06-13 15:10
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1219903&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Documentation
Group: Python 2.4
Status: Open
Resolution: None
Priority: 6
Submitted By: Barry A. Warsaw (bwarsaw)
Assigned to: Fred L. Drake, Jr. (fdrake)
Summary: tp_richcompare documentation wrong and incomplete
Initial Comment:
tp_richcompare slot as documented here:
http://www.python.org/doc/current/api/type-structs.html
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.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1219903&group_id=5470
More information about the Python-bugs-list
mailing list