Formatting Traceback info in the Python/C API

NG ngopalas at yahoo.com
Sun Mar 2 00:29:37 CET 2003


Hi everyone, I have a question. I want to format and print traceback
information using the C API. The reason I do not want to use
PyErr_Print() is because on Windows I want to capture the text
formatted traceback and put it up as a dialog box. I have looked over
the entire C API but cannot find a way to do it.

I want to do a

if (PyErr_Occurred()) {
PyObject *exception, *value, *traceback;
PyErr_Fetch(&exception,&value,&traceback);
/* Now I want to do something like what the traceback module does */
string = PyErr_FormatTraceback(traceback);
GuiDisplay(string);
}

Any help would be appreciated. I thought of importing the traceback
module in the C API and then do a PyCallObject(...) etc but that seems
like a very roundabout way of doing things.

Thanks,
NG




More information about the Python-list mailing list