mirror of
https://github.com/python/cpython.git
synced 2025-08-01 23:53:15 +00:00
Do not let overflows in enumerate() and count() pass silently.
This commit is contained in:
parent
de33c62466
commit
6d121f168c
3 changed files with 12 additions and 2 deletions
|
@ -62,6 +62,12 @@ enum_next(enumobject *en)
|
|||
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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue