[Python-Dev] [Python-checkins] cpython: Issue #14716: Change integer overflow check in unicode_writer_prepare()

Serhiy Storchaka storchaka at gmail.com
Mon May 7 17:48:36 CEST 2012


07.05.12 14:35, Mark Dickinson написав(ла):
> Hmm.  Very clever, but it's not obvious that that overflow check is
> mathematically sound.

My fault. Overflow will be at PY_SSIZE_T_MAX congruent to 4 modulo 5 
(which is impossible if PY_SSIZE_T_MAX is one less than a power of 2).

Mathematically strict limit must be
(PY_SSIZE_T_MAX - 1 - (PY_SSIZE_T_MAX - 4) / 5).



More information about the Python-Dev mailing list