[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


Hi,

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?
http://docs.python.org/3/c-api/arg.html

I would to parse an integer in [0; UINT_MAX] to fix the zlib module on
64-bit system:
http://bugs.python.org/issue18294

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

Victor


More information about the Python-Dev mailing list