[Zope3-dev] Excessive long traceback info in TALES

Steve Alexander steve@cat-box.net
Tue, 10 Dec 2002 17:46:54 +0000


Guido van Rossum wrote:
> When I make a simple mistake in a page template, I get a traceback.
> This traceback takes a very long time to render, due to two lines in
> Zope/PageTemplate/TALES.py, in the method evaluate():
> 
>         __traceback_supplement__ = (
>             TALESTracebackSupplement, self, expression)
> 
> I don't exactly understand what this is for, but I note that the class
> TALESTracebackSupplement (defined later in the same file) is
> apparently instantiated as part of displaying the traceback, and
> apparently one of the things it renders (without proper escaping of
> '<' and '>' !) is a dict of all the module in the system; this is a
> single line of about 16 KB in length.

This is because sys.modules is being rendered, whereas previous to a 
change made (by me) at the sprintathon, it was

   <security-proxied dict at 0x12345>


> I don't understand the code here (or its reason for existence) enough
> to know what's the right thing to do; but the problem is annoying, so
> I'd like to commit a band-aid solution, which would be to comment out
> those two lines from evaluate().

Marius and Jim are just about to commit a change that fixes this.

So, please don't apply your band-aid.


> 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.

--
Steve Alexander