You've got a couple problems here. First of all the PyTypeObject
type is specifically for the struct that defines a type. You can read more about type objects here: http://docs.python.org/2/c-api/typeobj.html It's not what you want though. For a pointer to an arbitrary Python object you want to use PyObject*
.
Second, the type code for an arbitrary Python object is "O"
(uppercase) not "o"
. If you want to do a type-check that it's a dictionary you can also use "O!"
This requires you to pass the address of a type object followed by the address of the PyObject*
you want to store the returned PyObject*
into. For example:
PyObject* dict;
PyArg_ParseTuple(args, "O!", &PyDict_Type, &dict);
This will return the object into the *dict pointer, and raise a TypeError
if it is not a dict. However unless you absolutely need it to be a dict I would recommend against this in favor of checking whether the object implements the mapping interface. But that's a different question.