File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -622,10 +622,19 @@ \subsection{Object Comparison}
622622and the \cfunction {PyObject_Compare()} or \cfunction {PyObject_Cmp()}
623623functions are used, or if \function {cmp()} is used from Python.)
624624It is analogous to the \method {__cmp__()} method. This function
625- should return a negative integer if \var {obj1} is less than
626- \var {obj2}, \code {0} if they are equal, and a positive integer if
625+ should return \code {-1} if \var {obj1} is less than
626+ \var {obj2}, \code {0} if they are equal, and \code {1} if
627627\var {obj1} is greater than
628628\var {obj2}.
629+ (It was previously allowed to return arbitrary negative or positive
630+ integers for less than and greater than, respectively; as of Python
631+ 2.2, this is no longer allowed. In the future, other return values
632+ may be assigned a different meaning.)
633+
634+ A \member {tp_compare} handler may raise an exception. In this case it
635+ should return a negative value. The caller has to test for the
636+ exception using \cfunction {PyErr_Occurred()}.
637+
629638
630639Here is a sample implementation:
631640
You can’t perform that action at this time.
0 commit comments