More verbose traceback

Irmen de Jong irmen at -NOSPAM-REMOVETHIS-xs4all.nl
Tue Feb 3 12:02:27 EST 2004


Thomas Guettler wrote:
> Hi!
> 
> Has someone written a script which
> dumps a traceback in a more verbose style?
> 
> This should include the information you
> see with cgitb. I like this very much.
> 
> You see the values of the important variables
> in the traceback. I need something like
> this, but it should be plain ascii, not html.

Have a look at the formatTraceback function in the util.py module of Pyro.
(http://pyro.sourceforge.net)   It prints tracebacks like this:

[IdJ] d:\>python test.py
--------------------------------------------------
  <exceptions.ZeroDivisionError> RAISED : integer division or modulo by zero
  Extended Stacktrace follows (most recent call last)
--------------------------------------------------
File "test.py", line (15), in ?
Source code:
     funcB("hello")
File "test.py", line (11), in funcB
Source code:
     result=funcA(1)
Local values:
                 localB = 'inside B'
--------------------------------------------------
File "test.py", line (7), in funcA
Source code:
     print arg/0
Local values:
                    arg = 1
                 localA = 999
--------------------------------------------------
  <exceptions.ZeroDivisionError> RAISED : integer division or modulo by zero
--------------------------------------------------


when used as follows:

try:
	...something...
except:
	print "".join(Pyro.util.formatTraceback( *sys.exc_info() ))



HTH,

--Irmen de Jong.



More information about the Python-list mailing list