returning traceback strings
mboedick at mboedick.org
Fri Jun 14 00:11:09 CEST 2002
I am looking for something exactly like traceback.print_exc(), but instead
of writing the traceback text to a filehandle, I want it to return it to
me as a string. I was unable to find any way to do this using the traceback
module, since everything there seems to be in terms of file handles being
The problem is I need to pass the entire multi-line traceback string to a
file-like object's write() method in one call, not line by line.
This is the best workaround I was able to come up with:
buf = cStringIO.StringIO()
Any suggestions for a better way? What about the traceback module using
strings internally, and wrapping another layer around that to write to files
and file-like objects?
Matthew Boedicker http://mboedick.org
More information about the Python-list