[Python-checkins] CVS: python/dist/src/Doc/ext newtypes.tex,1.3,1.4
Guido van Rossum
gvanrossum@users.sourceforge.net
Tue, 16 Oct 2001 13:32:07 -0700
Update of /cvsroot/python/python/dist/src/Doc/ext
In directory usw-pr-cvs1:/tmp/cvs-serv18927
Modified Files:
newtypes.tex
Log Message:
Document required return values -1, 0, 1 for tp_compare handler, as
suggested in SF patch #424475. Also document exception return.
Index: newtypes.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/ext/newtypes.tex,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** newtypes.tex 2001/09/26 22:26:45 1.3
--- newtypes.tex 2001/10/16 20:32:05 1.4
***************
*** 623,630 ****
functions are used, or if \function{cmp()} is used from Python.)
It is analogous to the \method{__cmp__()} method. This function
! should return a negative integer if \var{obj1} is less than
! \var{obj2}, \code{0} if they are equal, and a positive integer if
\var{obj1} is greater than
\var{obj2}.
Here is a sample implementation:
--- 623,639 ----
functions are used, or if \function{cmp()} is used from Python.)
It is analogous to the \method{__cmp__()} method. This function
! should return \code{-1} if \var{obj1} is less than
! \var{obj2}, \code{0} if they are equal, and \code{1} if
\var{obj1} is greater than
\var{obj2}.
+ (It was previously allowed to return arbitrary negative or positive
+ integers for less than and greater than, respectively; as of Python
+ 2.2, this is no longer allowed. In the future, other return values
+ may be assigned a different meaning.)
+
+ A \member{tp_compare} handler may raise an exception. In this case it
+ should return a negative value. The caller has to test for the
+ exception using \cfunction{PyErr_Occurred()}.
+
Here is a sample implementation: