[Python-Dev] new format codes for getargs.c
Tim Peters
tim.one@comcast.net
Fri, 21 Feb 2003 14:12:31 -0500
[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.