Problems sending list/tuple to a C extension.
seberino at spawar.navy.mil
Sun Nov 23 20:30:51 CET 2003
THANKS!! Everything works now!!! I really appreciate it.
This was really valuable help since this is really important
to know. It was reallly kind of you to look at my code and
help me out.
1. It seems very strange that checking/not checking return
value of PyArg_ParseTuple would make the difference
between working code and code that bombs. Not ALL code
is like this!!! I ignore lots of return codes and
things work fine lots of times!
Any idea why this API is so picky this way unlike others?
2. PyArg_ParseTuple string cannot have square brackets.
( "(ii)" is OK but "[ii]" is NOT OK )
However, I noticed if I call function with a list instead
of a tuple in "(ii)" case that it WORKS!!! So it seems
"(ii)" case takes care of tuples AND lists right??
This is also strange since Py_BuildValue accepts
"[ii]". Any ideas way Py_BuildValue likes square brackets
but PyArg_ParseTuple does not?
martin at v.loewis.de (Martin v. Löwis) wrote in message news:<m34qwv765s.fsf at mira.informatik.hu-berlin.de>...
> seberino at spawar.navy.mil (Christian Seberino) writes:
> > I hope the mistake in this simple code is obvious to you:
> There are two errors in your code:
> > PyArg_ParseTuple(args, "(i)", &a);
> You MUST check the return value of PyArg_ParseTuple. Otherwise,
> if it gives an exception, you just continue with incorrect data,
> which is what happened here.
> > >>> test.test( (3) )
> This does NOT pass a tuple, but an integer only. Use (3,) to display a
More information about the Python-list