[Python-bugs-list] [ python-Bugs-497067 ] Allow traceback analysis from C/C++...

noreply@sourceforge.net noreply@sourceforge.net
Thu, 27 Dec 2001 08:14:06 -0800


Bugs item #497067, was opened at 2001-12-27 08:13
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=497067&group_id=5470

Category: Python Interpreter Core
Group: Feature Request
Status: Open
Resolution: None
Priority: 5
Submitted By: Marcin Kasperski (marcinkasperski)
Assigned to: Nobody/Anonymous (nobody)
Summary: Allow traceback analysis from C/C++...

Initial Comment:
I write C++ applications which embed python 
interpreter as script engine. And I would like to 
perform traceback analysis during error handling 
(imagine for instance that I would like to include 
python traceback info inside some exception which 
will be handled outside library I write, maybe by 
sending error description to log server via network)

What I found? PyErr_Fetch gets traceback object and 
gives it to me. There are methods which print 
traceback to standard error. But if I want to do 
something different ... there is no way 
to analyze traceback  without utilizing some dirty 
tricks. Two main problems:
- struct tracebackobject is not present in python 
headers, it is only in traceback.c
- it is of course not documented at all.

I finally managed to do what I wanted by copying 
tracebackobject definition from traceback.c and by 
copying tb_printinternal and suiting it to my needs. 
But what will happen if you change this structure 
some time in the future?

What exactly do I request? Choose one of the two:

1) Either publish struct tracebackobject inside some 
Python headers (traceback.h?), mention in PyErr_Fetch 
documentation that the last parameter is of this type 
and describe its structure somewhere in python-embed

2) Or keep it secret but add some API which would 
allow to navigate traceback without presenting its 
internals, say the function like 
PyTrace_AnalyzeTraceBack which - given traceback 
object - would return file, line, name and next 
traceback (or the flag telling that there is no more).



----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=497067&group_id=5470