new format codes for getargs.c
![](https://secure.gravatar.com/avatar/b61315ad4ac9a887387d4ee835bd80c0.jpg?s=120&d=mm&r=g)
I've implemented a 'k' format code for getargs.c, and uploaded a patch for it http://www.python.org/sf/595026. This code accepts integers or longs, does no range checking, and returns the lower bits in an unsigned long. Is this also the fix for the hex constant issue which has been discussed here before? Are extension writers supposed to replace 'i' with 'k' in the PyArg_Parse calls in their extensions now? Then, I'm not sure how to proceed. Sure, a 'K' format code, which returns a LONG_LONG will also be needed, and I can implement that. Are the other changes proposed in the SF item (changes to the 'B', 'H', 'I' codes) needed? Do I have to add code somewhere to test these format codes or the Py.._From..Mask functions, probably in testcapi.c? Thomas
![](https://secure.gravatar.com/avatar/e79e2064f0ec68a0493ca5de758aeaa4.jpg?s=120&d=mm&r=g)
[Thomas Heller]
I've implemented a 'k' format code for getargs.c, and uploaded a patch for it http://www.python.org/sf/595026.
Cool! Thanks.
This code accepts integers or longs, does no range checking, and returns the lower bits in an unsigned long.
Is this also the fix for the hex constant issue which has been discussed here before? Are extension writers supposed to replace 'i' with 'k' in the PyArg_Parse calls in their extensions now?
Then, I'm not sure how to proceed.
Sure, a 'K' format code, which returns a LONG_LONG will also be needed, and I can implement that.
Are the other changes proposed in the SF item (changes to the 'B', 'H', 'I' codes) needed?
I suggest raising all these issues in comments on the patch report instead.
Do I have to add code somewhere to test these format codes or the Py.._From..Mask functions, probably in testcapi.c?
_testcapimodule.c, and yes. Most of that is devoted to ensuring that various range and integer size thingies work across platforms, and, especially if you're mucking with LONG_LONG, the chance of your code working across all 64-bit boxes the first time are close to 0 (unless you've done this often before): if this kind of thing isn't tested, it's broken.
participants (2)
-
Thomas Heller
-
Tim Peters