test_getargs2 fails on Win x64:
test_getargs2 is failing on Windows x64:
test test_getargs2 failed -- Traceback (most recent call last):
File
"S:\buildbots\python.x64\3.0.nelson-win64\build\lib\test\test_getargs2.py",
line 190, in test_n
self.failUnlessEqual(99, getargs_n(Long()))
TypeError: 'Long' object cannot be interpreted as an integer
The problem is twofold: case 'n' on Win x64 (where SIZEOF_SIZE_T !=
SIZEOF_LONG) had a broken code path and needed updating. Also, the
fallback to 'l' for systems where SIZEOF_SIZE_T == SIZEOF_LONG wasn't
correct -- it should still do a PyNumber_Index() check, and then use
PyLong_AsSize_t() to extract the value.
The attached patch corrects the behaviour on 32-bit and 64-bit systems,
including Windows. However, it has now uncovered another bug in Windows
x64:
>>> from _testcapi import getargs_n
>>> getargs_n(sys.maxsize)
9223372036854775807
>>> getargs_n(-sys.maxsize)
1
>>> getargs_n(-sys.maxsize-1)
0
After a bit of investigation with Martin, the logic in PyLong_AsSize_t()
is incorrect and needs to be reworked to handle negative maximums properly.