Traceback Questions

N

ncf

I'm just beginning with tracebacks, building off of what I see in
asyncore's compact_traceback code, in order to hopefully store all the
values from the location in which the exception occured.

I'm actually trying to make this into a python bug report system for my
current project, and am seeking advice on how to use sys.exc_info()[2]
better (the traceback element)

Does anyone have any advice on how I'd preform a traceback-based
bugreport-like system? The more I work on this, the more I'm confusing
myself. :\

-Wes



This is the code from which I'm slowly figuring out the traceback
stuff:
import sys,pprint
a,b = 1,0
def mth(a,b):
moo = a/b
try:
mth(a,b)
except:
pass
tb = sys.exc_info()[2]
assert tb
def sprint(o):
pprint.pprint(dict([(x, getattr(o, x)) for x in dir(o) if
x[:2]!='__']), indent=2)
sprint(tb)
sprint(tb.tb_frame)
sprint(tb.tb_frame.f_code)
 
F

Fernando Perez

ncf said:
I'm just beginning with tracebacks, building off of what I see in
asyncore's compact_traceback code, in order to hopefully store all the
values from the location in which the exception occured.

I'm actually trying to make this into a python bug report system for my
current project, and am seeking advice on how to use sys.exc_info()[2]
better (the traceback element)

Does anyone have any advice on how I'd preform a traceback-based
bugreport-like system? The more I work on this, the more I'm confusing
myself. :\

You may want to look at ipython's CrashHandler system:

http://projects.scipy.org/ipython/ipython/file/ipython/trunk/IPython/CrashHandler.py

It does all of what you've described in your post automatically. Some of it is
ipython-specific, but it should be easy enough to tweake it for your needs.

For download links (the above is an SVN source browsing link):

http://ipython.scipy.org

At some point I should really abstract this out, there seems to be a need for
it out there.

Cheers,

f
 
N

ncf

Thanks man, I'll definately take a look into this and hopefully port it
over and publish it.

Have a GREAT day

-Wes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,678
Members
48,796
Latest member
Greg L.

Latest Threads

Top