Repaired a few places where the PEP was incorrect or out of touch with

reality.  Specifically, the third argument to PyObject_RichCompare* is an int,
not an enum.  Also, when the tp_richcompare function cannot compare the
combination of objects, it needs to return Py_NotImplemented, not
PyExc_NotImplemented (and a new reference to that object at that).
This commit is contained in:
Barry Warsaw 2004-08-05 23:16:25 +00:00
parent 9d455a5e43
commit fe10049f8e
1 changed files with 4 additions and 3 deletions

View File

@ -140,13 +140,13 @@ Implementation Proposal
- New functions:
PyObject *PyObject_RichCompare(PyObject *, PyObject *, enum cmp_op)
PyObject *PyObject_RichCompare(PyObject *, PyObject *, int)
This performs the requested rich comparison, returning a Python
object or raising an exception. The 3rd argument must be one of
Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT or Py_GE.
int PyObject_RichCompareBool(PyObject *, PyObject *, enum cmp_op)
int PyObject_RichCompareBool(PyObject *, PyObject *, int)
This performs the requested rich comparison, returning a
Boolean: -1 for exception, 0 for false, 1 for true. The 3rd
@ -168,7 +168,8 @@ Implementation Proposal
At least one of the arguments is of the type whose
tp_richcompare slot is being used, but the other may have a
different type. If the function cannot compare the particular
combination of objects, it should return PyExc_NotImplemented.
combination of objects, it should return a new reference to
Py_NotImplemented.
- PyObject_Compare() is changed to try rich comparisons if they
are defined (but only if classic comparisons aren't defined).