I'm writing a C extension and I'm quite lost on how to receive a dict as an argument. As the docs don't have any specifics on how to achieve this I tried to parse the argument as a Python Object and then manipulate it as a dict:
PyTypeObject *dict;
if(!PyArg_ParseTuple(args, "o", &dict))
return NULL;
But the code fails on the parsing:
Python 2.7.2 (default, Jun 20 2012, 16:23:33)
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import plotting
>>> plotting.plot({'wff':0})
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: must be impossible<bad format char>, not dict
As far as I can understand from the error message the format char is wrong (I thought "o" should represent any Python object).
What is the best way to parse a Python dict to a C pointer? I'm digging through the documentation but I haven't found anything similar to this.
Thank you.