[Pyrex] Keyword argument problem with Python <= 2.4.1

Eric Huss e-huss at netmeridian.com
Mon Jul 17 01:06:40 UTC 2006


I've discovered a problem with keyword argument parsing with Python
versions 2.4.1 and earlier (the bug has been fixed in 2.4.2).

The PyArg_ParseTupleAndKeywords function has a bug when "skipping" over
keyword arguments that were not passed in.  A few data types are missing
from the "skip" code, and result in raising a TypeError (or, in some
cases, a core dump).  The following should illustrate the problem:


================================= [snip] =================================

def foo(unsigned int bar=0, bogus_keyword=None):
    print 'the value is %i' % bar

foo()
foo(1)
foo(bogus_keyword=2)

================================= [snip] =================================

This appears to only affect "unsigned int" and "unsigned long" in Pyrex.

The workaround is to not use these two data types as keyword arguments in
Pyrex functions, or upgrade to Python 2.4.2 or newer.

-Eric



More information about the Pyrex mailing list