[Python-checkins] CVS: python/dist/src/Doc/api api.tex,1.112,1.113

Fred L. Drake fdrake@users.sourceforge.net
Wed, 28 Mar 2001 13:14:35 -0800


Update of /cvsroot/python/python/dist/src/Doc/api
In directory usw-pr-cvs1:/tmp/cvs-serv16227/api

Modified Files:
	api.tex 
Log Message:

Added documentation for PyObject_IsInstance() and PyObject_IsSubclass().


Index: api.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/api/api.tex,v
retrieving revision 1.112
retrieving revision 1.113
diff -C2 -r1.112 -r1.113
*** api.tex	2001/03/23 17:42:09	1.112
--- api.tex	2001/03/28 21:14:32	1.113
***************
*** 1494,1497 ****
--- 1494,1533 ----
  \end{cfuncdesc}
  
+ \begin{cfuncdesc}{int}{PyObject_IsInstance}{PyObject *inst, PyObject *cls}
+ Return \code{1} if \var{inst} is an instance of the class \var{cls} or
+ a subclass of \var{cls}.  If \var{cls} is a type object rather than a
+ class object, \cfunction{PyObject_IsInstance()} returns \code{1} if
+ \var{inst} is of type \var{cls}.  If \var{inst} is not a class
+ instance and \var{cls} is neither a type object or class object,
+ \var{inst} must have a \member{__class__} attribute --- the class
+ relationship of the value of that attribute with \var{cls} will be
+ used to determine the result of this function.
+ \versionadded{2.1}
+ \end{cfuncdesc}
+ 
+ Subclass determination is done in a fairly straightforward way, but
+ includes a wrinkle that implementors of extensions to the class system
+ may want to be aware of.  If \class{A} and \class{B} are class
+ objects, \class{B} is a subclass of \class{A} if it inherits from
+ \class{A} either directly or indirectly.  If either is not a class
+ object, a more general mechanism is used to determine the class
+ relationship of the two objects.  When testing if \var{B} is a
+ subclass of \var{A}, if \var{A} is \var{B},
+ \cfunction{PyObject_IsSubclass()} returns true.  If \var{A} and
+ \var{B} are different objects, \var{B}'s \member{__bases__} attribute
+ is searched in a depth-first fashion for \var{A} --- the presence of
+ the \member{__bases__} attribute is considered sufficient for this
+ determination.
+ 
+ \begin{cfuncdesc}{int}{PyObject_IsSubclass}{PyObject *derived,
+                                             PyObject *cls}
+ Returns \code{1} if the class \var{derived} is identical to or derived
+ from the class \var{cls}, otherwise returns \code{0}.  In case of an
+ error, returns \code{-1}.  If either \var{derived} or \var{cls} is not
+ an actual class object, this function uses the generic algorithm
+ described above.
+ \versionadded{2.1}
+ \end{cfuncdesc}
+ 
  
  \begin{cfuncdesc}{int}{PyCallable_Check}{PyObject *o}