incorrect line reported in traceback

Patrick Stinson patrickstinson.lists at gmail.com
Mon Dec 1 01:05:35 EST 2008


No, I've embedded the interpreter and an editor in my app, which might
have something to do with it. I can't run the scripts at the command
line because my app provides an API to built-ins that isn't availbel
in the standard interpreter. I am simply calling a python method in
the script module using PyObject_CallObject(), and fetching the
traceback using PyErr_Fetch() and PyErr_Normalize(), like this:

	PyObject *type, *value, *traceback;

	PyErr_Fetch(&type, &value, &traceback);
	PyErr_NormalizeException(&type, &value, &traceback);

    if(traceback) // traceback.tb_lineno
      *lineno = ((PyTracebackObject *) traceback)->tb_lineno;

On Sun, Nov 30, 2008 at 8:59 PM, John Machin <sjmachin at lexicon.net> wrote:
> On Dec 1, 4:47 pm, "Patrick Stinson" <patrickstinson.li... at gmail.com>
> wrote:
>> Is there any reason why the last item in the traceback is one frame
>> below the top of the stack? It would be great to show the real line in
>> my editor...
>
> Maybe your anonymous [HINT!] editor is confused. Do you get the same
> problem when you run your script at the shell prompt?
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list