
Hello Guido, On Wed, Nov 27, 2002 at 08:07:21PM -0500, Guido van Rossum wrote:
But in Mark's case (and in many other cases) there will be no problem in the future -- in Python 2.4, his C code will happily accept the positive Python longs that 0x80000000 and others will be then.
As it stands, there is no good solution for Python 2.3: you have to use 0x80000000 in your Python code because 0x80000000L will cause PyArg_ParseTuple("i") to fail, and if you use 0x80000000 you get warnings that you cannot silence unless you write -2147483648... So it seems that "i" must already accept longs up to 0xffffffffL in Python 2.3. I already feel a certain confusion about the various decoders of PyArg_ParseTuple(), and I fear that this will only add more, given that these codes are similar but not identical to what we have in the struct module -- and the latter is also pretty obscure about the exact range of accepted values. I'm volunteering to add format codes to PyArg_ParseTuple, hoping that we can find some common ground and consistently add them to the struct module as well. Sadly, it seems that the two sets of format codes are definitely incompatible. Indeed, 'b' is unsigned and 'B' signed in PyArg_ParseTuple, and the converse in struct... And 'B' and 'H' are not documented for PyArg_ParseTuple!? Armin