PyArg_ParseTuple part 2

John john.thai at dspfactory.com
Wed Jun 13 13:33:20 EDT 2001


Hi,

    In an extended python c function, I use PyArg_ParseTuple to extract a
list object from python.  I then use PyList_AsTuple to get a tuple version
of the list.  I'm expecting an list of 2 integers, so I use PyArg_ParseTuple
again, passing in this new derived tuple, and specifying "ii".  Should this
not work?  First, after I call PyList_AsTuple, I get NULL back instead of a
PyObject.  Second, lets say I pass variable x (from python) = [1,2] into my
function, right after making this function call foo(x), no matter what I
type, either x, or just enter, I get the following msg:

SystemError: C:\Code\python\dist\src\Objects\listobject.c:1317: bad argument
to
internal function

Anyone know what's going on?

Related questions:  Is there a fast way of extracting elements from a list,
other than using PyList_GetItem, then converting the PyObject into the type
you are looking for?  And why isn't there a PyInt_FromInt(int) function?

Thanks,

John





More information about the Python-list mailing list