Martin Panter added the comment: Hmm maybe this patch is okay. We are assuming size_t will fit more than PY_SSIZE_T_MAX.
The alternatives I can think of would be equally ugly: /* Risks loss of precision, e.g. 64 bit integer from floating point */ if (n < (Py_ssize_t)(PY_SSIZE_T_MAX / 1.25) - 10)) /* PY_SSIZE_T_MAX * 4/5 - 10 without loss of precision or overflowing */ if (n < PY_SSIZE_T_MAX / 5 * 4 + PY_SSIZE_T_MAX % 5 * 4 / 5 - 10) ---------- stage: -> patch review _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27581> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com