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
|
@ -2073,6 +2073,11 @@ count_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
|||
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++);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue