From: moerchendiser2k3 on
In one case I have to check the return value of PyObject_Call, and if
its not of the correct return value,
I throw an exception, but I just get a simple output:

TypeError: Expected an instance of XYZ, no int.

instead of

Traceback (most called...)
TypeError: in line 3, file test.py: expected an instance of XYZ, no
int...
From: Steve Holden on
moerchendiser2k3 wrote:
> In one case I have to check the return value of PyObject_Call, and if
> its not of the correct return value,
> I throw an exception, but I just get a simple output:
>
> TypeError: Expected an instance of XYZ, no int.
>
> instead of
>
> Traceback (most called...)
> TypeError: in line 3, file test.py: expected an instance of XYZ, no
> int...

Could we perhaps see a little bit more of the code? Are you throwing the
exception from within your C code or from the Python calling environment
with a raise statement?

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
See PyCon Talks from Atlanta 2010 http://pycon.blip.tv/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS: http://holdenweb.eventbrite.com/

From: moerchendiser2k3 on
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?

Bye, moerchendiser2k3
From: Carl Banks on
On Mar 16, 11:25 am, moerchendiser2k3 <googler.
1.webmas...(a)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
From: moerchendiser2k3 on
At first thanks for your answers!!!

On 16 Mrz., 21:16, Carl Banks <pavlovevide...(a)gmail.com> wrote:
> 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.

Exactly, I dont expect any line/file information. I am just looking
forward for a solution how to solve that. I would like to avoid
the use of the debugger in this case.

My ideas:

1. I thought the return value might contain any information where it
is from.
2. Otherwise it would be cool if there are any information available
in which line, file
the last called function/method exited.

Bye, moerchendiser2k3