Clement Rouault added the comment:

> Also, PY_SSIZE_T_MAX is a valid value to pass to PySequence_GetItem(), so it 
> shouldn't be blocked unless necessary.

I agree with you, that's why my first path was checking at the next call if 
it->it_index had overflowed. But then it relies on undefined behaviour.

> I would think that the PY_SSIZE_T_MAX check belongs inside the:
> 
>     if (result != NULL) {
>         it->it_index++;
>         return result;
>     }

If we raise the OverflowError when it->it_index really overflow (just after the 
getitem PY_SSIZE_T_MAX).
Is it really necessary to do the overflow check after the GetItem ? because the 
value returned by `PySequence_GetItem(seq, PY_SSIZE_T_MAX);` will be never used.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue22939>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to