hi,
I have written a trace function in C using the Python/C API. I want to
find whether the call occured is a function call or method call and if
a method call, its self object.
int tracer(PyObject *obj, PyObject *f, int what, PyObject *args){
PyObject *item,*SelfItem;
switch(what){
case PyTrace_CALL: {
printf("%s",PyString_AS_STRING(f->f_code->co_name));
if(f->f_code->co_argcount>0 &&
strcmp(PyString_AS_STRING(PyTuple_GetItem(f->f_code->co_varnames,0),"self")==0)
{
//checks if the call is a method call
printf("Method\n");
SelfItem = f->f_locals;
} else printf("Function");
} }
The SelfItem obtained is a NULL object (for method call).But when I
wrote the same trace function in python, f->f_locals is a dictionary
with "self" as a keyword.
How can i get the dictionary in C?
Thanks,
Vijay.