开发者

How to find out what function the Python interpreter is calling from callable PyObject?

I'm trying to trace through the Python source code where a certain function is actually called and how to get its name.

In abstract.c:

PyObject *
PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw)
{
    ternaryfunc call;
    if((call = func->ob_type->tp_name) != NULL){ 
        PyObject *result;
        ...
        result = (*call)(func, arg, kw); //How do I find out what is being called here?
        ...
    }
    ...
}

At the line with my comment, how can I get the name of what is being called? I'm able to get the object type through (char *)func->ob_type-开发者_JAVA技巧>tp_name, but I want to know the name of the function being called. (args would be nice, too)

Note: I'm working with Python 2.6.


The __name__ attribute of the function object should contain the name. The arguments are in arg as a tuple and kw as a dict.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜