[Python-checkins] CVS: python/dist/src/Doc/api abstract.tex,1.9,1.10

Fred L. Drake fdrake@users.sourceforge.net
Mon, 11 Mar 2002 10:46:31 -0800


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

Modified Files:
	abstract.tex 
Log Message:
Documentation for PyObject_GetIter(), contributed by Greg Chapman
(with only minor changes by Fred).
This closes SF bug #498607.


Index: abstract.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/api/abstract.tex,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** abstract.tex	26 Dec 2001 16:53:48 -0000	1.9
--- abstract.tex	11 Mar 2002 18:46:29 -0000	1.10
***************
*** 308,311 ****
--- 308,319 ----
  \end{cfuncdesc}
  
+ \begin{cfuncdesc}{PyObject*}{PyObject_GetIter}{PyObject *o}
+   This is equivalent to the Python expression \samp{iter(\var{o})}.
+   It returns a new iterator for the object argument, or the object 
+   itself if the object is already an iterator.  Raises
+   \exception{TypeError} and returns \NULL{} if the object cannot be
+   iterated.
+ \end{cfuncdesc}
+ 
  
  \section{Number Protocol \label{number}}
***************
*** 856,863 ****
  
  \begin{verbatim}
! PyObject *iterator = ...;
  PyObject *item;
  
! while (item = PyIter_Next(iter)) {
      /* do something with item */
      ...
--- 864,875 ----
  
  \begin{verbatim}
! PyObject *iterator = PyObject_GetIter(obj);
  PyObject *item;
  
! if (iterator == NULL) {
!     /* propagate error */
! }
! 
! while (item = PyIter_Next(iterator)) {
      /* do something with item */
      ...
***************
*** 865,870 ****
      Py_DECREF(item);
  }
  if (PyErr_Occurred()) {
!     /* propogate error */
  }
  else {
--- 877,885 ----
      Py_DECREF(item);
  }
+ 
+ Py_DECREF(iterator);
+ 
  if (PyErr_Occurred()) {
!     /* propagate error */
  }
  else {