[Zope3-dev] Excessive long traceback info in TALES
Guido van Rossum
guido@python.org
Tue, 10 Dec 2002 13:07:16 -0500
> Marius and Jim are just about to commit a change that fixes this.
>
> So, please don't apply your band-aid.
Cool. I saw that was on a branch though -- can I port it to the trunk?
> > BTW, Python 2.2 and later have a module "cgitb" which formats a
> > traceback in a nice way. Using it is as simple as calling
> > cgitb.html(sys.info()).
> >
> > Maybe this could be used to replace the current sub-optimal traceback
> > (with no source code) that gets displayed?
>
> Sounds like a useful thing.
To see for yourself, add this:
Index: ExceptionFormatter.py
===================================================================
RCS file: /cvs-repository/Zope3/lib/python/Zope/Exceptions/ExceptionFormatter.py,v
retrieving revision 1.5
diff -c -c -r1.5 ExceptionFormatter.py
*** ExceptionFormatter.py 1 Aug 2002 18:42:18 -0000 1.5
--- ExceptionFormatter.py 10 Dec 2002 18:05:30 -0000
***************
*** 233,240 ****
--- 233,246 ----
def format_exception(t, v, tb, limit=None, as_html=0):
if as_html:
+ ## XXX GvR: experimental hack to use cgitb
+ import cgitb
+ return cgitb.html((t, v, tb))
fmt = html_formatter
else:
+ # XXX GvR: show standard Python traceback
+ import traceback
+ return "\n".join(traceback.format_exception())
fmt = text_formatter
return fmt.formatException(t, v, tb)
(The second half of the patch replaces the custom formatter with the
standard formatter, which at least shows source lines.)
Having tried it, I think cgitb.html() may be a little too verbose.
What do you think?
--Guido van Rossum (home page: http://www.python.org/~guido/)