[Python-checkins] python/dist/src/Python bltinmodule.c,2.254,2.255
tim_one@sourceforge.net
tim_one@sourceforge.net
Sun, 12 May 2002 00:19:40 -0700
Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv21915/python/Python
Modified Files:
bltinmodule.c
Log Message:
SF bug 555042: zip() may trigger MemoryError.
NOT a bugfix candidate: this is a fix to an optimization introduced
in 2.3.
Index: bltinmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v
retrieving revision 2.254
retrieving revision 2.255
diff -C2 -d -r2.254 -r2.255
*** bltinmodule.c 29 Apr 2002 21:27:32 -0000 2.254
--- bltinmodule.c 12 May 2002 07:19:38 -0000 2.255
***************
*** 1718,1728 ****
assert(PyTuple_Check(args));
! /* Guess at result length: the shortest of the input lengths. */
len = -1; /* unknown */
for (i = 0; i < itemsize; ++i) {
PyObject *item = PyTuple_GET_ITEM(args, i);
int thislen = PySequence_Length(item);
! if (thislen < 0)
PyErr_Clear();
else if (len < 0 || thislen < len)
len = thislen;
--- 1718,1733 ----
assert(PyTuple_Check(args));
! /* Guess at result length: the shortest of the input lengths.
! If some argument refuses to say, we refuse to guess too, lest
! an argument like xrange(sys.maxint) lead us astray.*/
len = -1; /* unknown */
for (i = 0; i < itemsize; ++i) {
PyObject *item = PyTuple_GET_ITEM(args, i);
int thislen = PySequence_Length(item);
! if (thislen < 0) {
PyErr_Clear();
+ len = -1;
+ break;
+ }
else if (len < 0 || thislen < len)
len = thislen;