Mercurial > cpython-lru_cache-weakref
diff Objects/enumobject.c @ 40766:1ad0568737f6 legacy-trunk
Do not let overflows in enumerate() and count() pass silently.
| author | Raymond Hettinger <python@rcn.com> |
|---|---|
| date | Thu, 08 Feb 2007 00:07:32 +0000 |
| parents | 7b2e436a4a21 |
| children | 6620a510e9a9 |
line wrap: on
line diff
--- a/Objects/enumobject.c Wed Feb 07 23:49:03 2007 +0000 +++ b/Objects/enumobject.c Thu Feb 08 00:07:32 2007 +0000 @@ -62,6 +62,12 @@ PyObject *result = en->en_result; PyObject *it = en->en_sit; + if (en->en_index == LONG_MAX) { + PyErr_SetString(PyExc_OverflowError, + "enumerate() is limited to LONG_MAX items"); + return NULL; + } + next_item = (*it->ob_type->tp_iternext)(it); if (next_item == NULL) return NULL;
