commit | 6d121f168cca9df59fe4b3908cecbc346e185650 | [log] [tgz] |
---|---|---|
author | Raymond Hettinger <python@rcn.com> | Thu Feb 08 00:07:32 2007 +0000 |
committer | Raymond Hettinger <python@rcn.com> | Thu Feb 08 00:07:32 2007 +0000 |
tree | fe8629589e827fe1f8803b5fb90d871e017c7bff | |
parent | de33c62466c688d0769744a7503d8e969bce5741 [diff] [blame] |
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++); }