July 27, 2009
9:05 p.m.
Shaun Savage <savages@mozapps.org> writes:
I am trying to create a new python object of type Foo from a C program.
typedef struct ( PyObject_HEAD PyObject ...., ... } Foo;
static PyTypeObject FooType = { PyObject_HEAD_INIT(NULL) 0, "foo.Foo", sizeof(Foo), 0, ... }
in the code i have
self = (Foo*) PyObject_CallObject((PyObject*)&FooType, NULL);
You need to use PyObject_CallFunctionObjArgs, like this:
self = (Foo *)PyObject_CallFunctionObjArgs((PyObject*)&FooType, NULL);
PyObject_CallObject is when you already have an argument tuple at the ready.