C-API PyObject_Call

Carl Banks pavlovevidence at gmail.com
Tue Mar 16 16:16:50 EDT 2010


On Mar 16, 11:25 am, moerchendiser2k3 <googler.
1.webmas... at spamgourmet.com> wrote:
> Hi, currently I am not at home, I will post some stuff when I am back.
> Just the note: I throw an exception with the C API.
>
> Looks like that
>
> PyObject *result = PyObject_Call(my_isntance, "", NULL);
> if(result==NULL)
> {
>     PyErr_Print(); //when this happens, the traceback is correct with
> information about the file/line
>     return;
>
> }
>
> if(!PyXYZ_Check(result))
> {
>     PyErr_SetString(PyExc_TypeError, "Wrong type, ....");
>     PyErr_Print(); //missing information of the file/line.
>     return;
> }
>
> Well, I expect, that there are no information about the line/file, so
> I know something is missing, but what is missing?

Python tracebacks only contain line/file information about Python
files, not C files.  Here you raise an exception with a C statement,
and catch and print it in the very next line.  The exception doesn't
exit from Python code so there are no lines to print.

What line/file data you do expect to see?

If you want to see C line/file informnation you have to use a debugger
like gdb, as Steve Holden said.


Carl Banks



More information about the Python-list mailing list