[Python-checkins] python/dist/src/Modules itertoolsmodule.c, 1.32, 1.33

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Sat May 8 15:49:44 EDT 2004


Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2267/Modules

Modified Files:
	itertoolsmodule.c 
Log Message:
SF #950057:  itertools.chain doesn't "process" exceptions as they occur

Both cycle() and chain() were handling exceptions only when switching
input sources.  The patch makes the handle more immediate.

Will backport.



Index: itertoolsmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/itertoolsmodule.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -d -r1.32 -r1.33
*** itertoolsmodule.c	13 Apr 2004 02:43:53 -0000	1.32
--- itertoolsmodule.c	8 May 2004 19:49:42 -0000	1.33
***************
*** 700,703 ****
--- 700,709 ----
  			return item;
  		}
+ 		if (PyErr_Occurred()) {
+ 			if (PyErr_ExceptionMatches(PyExc_StopIteration))
+ 				PyErr_Clear();
+ 			else
+ 				return NULL;
+ 		}
  		if (PyList_Size(lz->saved) == 0) 
  			return NULL;
***************
*** 1659,1662 ****
--- 1665,1674 ----
  		if (item != NULL)
  			return item;
+ 		if (PyErr_Occurred()) {
+ 			if (PyErr_ExceptionMatches(PyExc_StopIteration))
+ 				PyErr_Clear();
+ 			else
+ 				return NULL;
+ 		}
  		lz->iternum++;
  	}




More information about the Python-checkins mailing list