commit | 9f0e1ea96402bf6fa72560640777bf8c3bd186fb | [log] [tgz] |
---|---|---|
author | Raymond Hettinger <python@rcn.com> | Wed Feb 07 23:57:05 2007 +0000 |
committer | Raymond Hettinger <python@rcn.com> | Wed Feb 07 23:57:05 2007 +0000 |
tree | 8afe516eec3490fd24da7bdb3a2479ec0688c8ce | |
parent | bbe92887ced108cb7ffac2fa037e72981920f21f [diff] |
Do not let overflows in enumerate() and count() pass silently.
diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c index 7896143..70f787f 100644 --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c
@@ -2073,6 +2073,11 @@ static PyObject * count_next(countobject *lz) { + if (lz->cnt == LONG_MAX) { + PyErr_SetString(PyExc_OverflowError, + "cannot count beyond LONG_MAX"); + return NULL; + } return PyInt_FromSsize_t(lz->cnt++); }