Antti Haapala added the comment:

if (len == PY_SSIZE_T_MAX) is necessary for the case that the iterable is 
already PY_SSIZE_T_MAX items. However it could be moved inside the *other* if 
because if (len == PY_SSIZE_T_MAX) should also fail the overflow check.

However, I believe it is theoretical at most with stuff that Python supports 
that it would even be possible to allocate an array of PY_SSIZE_T_MAX 
*pointers*. The reason is that the maximum size of object can be only that of 
`size_t`, and Py_ssize_t should be a signed type of that size; and it would 
thus be possible only to allocate an array of PY_SSIZE_T_MAX pointers only if 
they're 16 bits wide.

In any case, this would be another place where my proposed macro 
"SUM_OVERFLOWS_PY_SSIZE_T" or something would be in order to make it read

    if (SUM_OVERFLOWS_PY_SSIZE_T(len, (len >> 1) + 1)

which would make it easier to spot mistakes in the sign preceding 1.

----------
nosy: +ztane

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

Reply via email to