[Python-checkins] CVS: python/dist/src/Objects iterobject.c,1.1.2.1,1.1.2.2

Guido van Rossum gvanrossum@usw-pr-cvs1.sourceforge.net
Tue, 13 Mar 2001 04:15:47 -0800


Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv5217

Modified Files:
      Tag: iter-branch
	iterobject.c 
Log Message:
The call-wrapping iterator should not overload 'value' as either a
return value or an exception.  It should turn IndexError, if raised,
into a TypeError to avoid silently terminating the sequence.

Also added two missing casts to the type structure initializers.


Index: iterobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/Attic/iterobject.c,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -r1.1.2.1 -r1.1.2.2
*** iterobject.c	2001/03/13 10:07:42	1.1.2.1
--- iterobject.c	2001/03/13 12:15:44	1.1.2.2
***************
*** 71,75 ****
  	0,					/* tp_as_mapping */
  	0,					/* tp_hash */
! 	iter_call,				/* tp_call */
  	0,					/* tp_str */
  	0,					/* tp_getattro */
--- 71,75 ----
  	0,					/* tp_as_mapping */
  	0,					/* tp_hash */
! 	(ternaryfunc)iter_call,			/* tp_call */
  	0,					/* tp_str */
  	0,					/* tp_getattro */
***************
*** 125,135 ****
  	}
  	else {
! 		if (PyErr_ExceptionMatches(it->it_sentinel))
! 			PyErr_SetObject(PyExc_IndexError, Py_None);
! 		else if (PyErr_ExceptionMatches(PyExc_IndexError) &&
! 		      !PyErr_GivenExceptionMatches(
! 				PyExc_IndexError, it->it_sentinel))
  			PyErr_SetString(PyExc_TypeError,
! 				"callable in iterator raised unexpected IndexError");
  	}
  	return result;
--- 125,132 ----
  	}
  	else {
! 		if (PyErr_ExceptionMatches(PyExc_IndexError))
  			PyErr_SetString(PyExc_TypeError,
! 					"callable in iterator raised "
! 					"unexpected IndexError");
  	}
  	return result;
***************
*** 153,157 ****
  	0,					/* tp_as_mapping */
  	0,					/* tp_hash */
! 	calliter_call,				/* tp_call */
  	0,					/* tp_str */
  	0,					/* tp_getattro */
--- 150,154 ----
  	0,					/* tp_as_mapping */
  	0,					/* tp_hash */
! 	(ternaryfunc)calliter_call,		/* tp_call */
  	0,					/* tp_str */
  	0,					/* tp_getattro */