summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2002-05-12 07:19:38 (GMT)
committerTim Peters <tim.peters@gmail.com>2002-05-12 07:19:38 (GMT)
commit39a86c2188b22818c187e860fbf7d77a28a6a116 (patch)
tree3f4ba33fb67e240057bfdb757cbf0343fc076978 /Python
parent9b1df1db684e5f7f0ab22e423d9858ee5cd340d9 (diff)
downloadcpython-39a86c2188b22818c187e860fbf7d77a28a6a116.zip
cpython-39a86c2188b22818c187e860fbf7d77a28a6a116.tar.gz
cpython-39a86c2188b22818c187e860fbf7d77a28a6a116.tar.bz2
SF bug 555042: zip() may trigger MemoryError.
NOT a bugfix candidate: this is a fix to an optimization introduced in 2.3.
Diffstat (limited to 'Python')
-rw-r--r--Python/bltinmodule.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index fb6810e..d0411e2 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -1717,13 +1717,18 @@ builtin_zip(PyObject *self, PyObject *args)
/* args must be a tuple */
assert(PyTuple_Check(args));
- /* Guess at result length: the shortest of the input lengths. */
+ /* 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)
+ if (thislen < 0) {
PyErr_Clear();
+ len = -1;
+ break;
+ }
else if (len < 0 || thislen < len)
len = thislen;
}