[Python-Dev] PyArg_ParseTupe(): parse unsigned integer and check for overflow

Victor Stinner victor.stinner at gmail.com
Thu Jun 27 00:07:11 CEST 2013


I don't understand why the B, H, I, k formats of PyArg_ParseTupe() do
not check for overflow, whereas formats for signed numbers do check
for overflow. What is the useful of ignoring overflow?

I would to parse an integer in [0; UINT_MAX] to fix the zlib module on
64-bit system:

How should I implement that? Use "O" format and then use
PyLong_Check(), PyLong_AsLong(), and check value <= UINT_MAX?


More information about the Python-Dev mailing list