Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > f->f_locals is NULL for a method call

Reply
Thread Tools

f->f_locals is NULL for a method call

 
 
Vijay Kumar
Guest
Posts: n/a
 
      05-27-2005
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
createImage sometime returns null and sometime returns non-null. vizlab Java 3 10-17-2007 11:21 AM
Cannot invoke Call with null namespace URI for method null raviupasi@gmail.com Java 0 05-12-2006 01:34 PM
"stringObj == null" vs "stringObj.equals(null)", for null check?? qazmlp1209@rediffmail.com Java 5 03-29-2006 10:37 PM
null parameter in method call different in 1.4 v.s. 1.5? mingclee1@gmail.com Java 10 08-02-2005 04:30 PM
VB.NET Null to SQL Null (ASP.NET 2.0 GridView) Kivak Wolf ASP .Net 2 06-28-2005 02:01 PM



Advertisments