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

Fred L. Drake python-dev@python.org
Wed, 29 Nov 2000 07:48:26 -0800


Update of /cvsroot/python/python/dist/src/Doc/api
In directory slayer.i.sourceforge.net:/tmp/cvs-serv10145/api

Modified Files:
	api.tex 
Log Message:

In the first discussion showing how to handle exceptions from C, make the
Python equivalent actually equivalent to the C code.  Also, in the C code,
place the "goto" statements on a line by themselves for better visibility
of statements that affect control flow.

This closes bug #123398.


Index: api.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/api/api.tex,v
retrieving revision 1.98
retrieving revision 1.99
diff -C2 -r1.98 -r1.99
*** api.tex	2000/11/28 22:34:32	1.98
--- api.tex	2000/11/29 15:48:22	1.99
***************
*** 457,461 ****
      except KeyError:
          item = 0
!     return item + 1
  \end{verbatim}
  \ttindex{incr_item()}
--- 457,461 ----
      except KeyError:
          item = 0
!     dict[key] = item + 1
  \end{verbatim}
  \ttindex{incr_item()}
***************
*** 473,491 ****
      if (item == NULL) {
          /* Handle KeyError only: */
!         if (!PyErr_ExceptionMatches(PyExc_KeyError)) goto error;
  
          /* Clear the error and use zero: */
          PyErr_Clear();
          item = PyInt_FromLong(0L);
!         if (item == NULL) goto error;
      }
- 
      const_one = PyInt_FromLong(1L);
!     if (const_one == NULL) goto error;
  
      incremented_item = PyNumber_Add(item, const_one);
!     if (incremented_item == NULL) goto error;
  
!     if (PyObject_SetItem(dict, key, incremented_item) < 0) goto error;
      rv = 0; /* Success */
      /* Continue with cleanup code */
--- 473,495 ----
      if (item == NULL) {
          /* Handle KeyError only: */
!         if (!PyErr_ExceptionMatches(PyExc_KeyError))
!             goto error;
  
          /* Clear the error and use zero: */
          PyErr_Clear();
          item = PyInt_FromLong(0L);
!         if (item == NULL)
!             goto error;
      }
      const_one = PyInt_FromLong(1L);
!     if (const_one == NULL)
!         goto error;
  
      incremented_item = PyNumber_Add(item, const_one);
!     if (incremented_item == NULL)
!         goto error;
  
!     if (PyObject_SetItem(dict, key, incremented_item) < 0)
!         goto error;
      rv = 0; /* Success */
      /* Continue with cleanup code */