C-API: Extract information from function object

M

moerchendiser2k3

Hi,

I have a reference to a function and would like to know how to extract
information from a function object.

Information I am looking for: line and file where this function is
from.

PyObject_Call can do this to when I call a function object and
something failed so these information are written to the traceback. So
any suggestions how to do that?

Thx!! moerchendiser2k3
 
G

Gabriel Genellina

En Wed, 24 Mar 2010 12:09:27 -0300, moerchendiser2k3
I have a reference to a function and would like to know how to extract
information from a function object.

Information I am looking for: line and file where this function is
from.

PyObject_Call can do this to when I call a function object and
something failed so these information are written to the traceback. So
any suggestions how to do that?

See the Language Reference; the associated code object holds the file and
starting line the function comes from.
The traceback object contains better information (like the line being
executed instead of the first one). Why don't you use it instead?
 
S

Stefan Behnel

Gabriel Genellina, 24.03.2010 17:49:
En Wed, 24 Mar 2010 12:09:27 -0300, moerchendiser2k3 escribió:


See the Language Reference; the associated code object holds the file
and starting line the function comes from.
The traceback object contains better information (like the line being
executed instead of the first one). Why don't you use it instead?

Note that this was a follow-up to another recent thread where I managed to
extract the details from the OP by stoically asking back, especially the
information that this is not about exception handling but rather about
reporting incorrect return values.

This is a good example when you need a reason why not to split threads on
the same subject...

Stefan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top