1 message in org.python.python-bugs-list[ python-Bugs-497067 ] Allow tracebac...
FromSent OnAttachments
SourceForge.netMar 21, 2004 1:48 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:[ python-Bugs-497067 ] Allow traceback analysis from C/C++...Actions...
From:SourceForge.net (nore@sourceforge.net)
Date:Mar 21, 2004 1:48:31 pm
List:org.python.python-bugs-list

Bugs item #497067, was opened at 2001-12-27 11:13 Message generated for change (Settings changed) made by mondragon You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=497067&group_id=5470

Category: Python Interpreter Core Group: Feature Request

Status: Closed Resolution: Fixed

Priority: 3 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).

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

Comment By: Nick Bastin (mondragon)

Date: 2004-03-21 13:48

Message: Logged In: YES user_id=430343

Fixed in: Include/traceback.h 2.21 Python/traceback.c 2.42 Misc/NEWS 1.955

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

Comment By: Guido van Rossum (gvanrossum) Date: 2001-12-27 11:35

Message: Logged In: YES user_id=6380

I agree that this API should be published in a header file.

The Python API to the traceback object is documented so you can always use PyObject_GetAttrString(tb, "tb_frame") and so on.

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