[Python-checkins] python/dist/src/Modules arraymodule.c,2.89,2.90

doerwalter@users.sourceforge.net doerwalter@users.sourceforge.net
Fri, 23 May 2003 03:01:10 -0700


Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1:/tmp/cvs-serv30268/Modules

Modified Files:
	arraymodule.c 
Log Message:
All calls to getarrayitem() (which is static) are done either in loops
over the size of the array, or the callers check the index bounds themselves,
so the index check never failed => Replace it with an assert().


Index: arraymodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/arraymodule.c,v
retrieving revision 2.89
retrieving revision 2.90
diff -C2 -d -r2.89 -r2.90
*** arraymodule.c	18 May 2003 03:15:10 -0000	2.89
--- arraymodule.c	23 May 2003 10:01:07 -0000	2.90
***************
*** 448,455 ****
  	assert(array_Check(op));
  	ap = (arrayobject *)op;
! 	if (i < 0 || i >= ap->ob_size) {
! 		PyErr_SetString(PyExc_IndexError, "array index out of range");
! 		return NULL;
! 	}
  	return (*ap->ob_descr->getitem)(ap, i);
  }
--- 448,452 ----
  	assert(array_Check(op));
  	ap = (arrayobject *)op;
! 	assert(i>=0 && i<ap->ob_size);
  	return (*ap->ob_descr->getitem)(ap, i);
  }