[Zope] Cool monkey patch to make tracebacks more useful :-)

Chris Withers chris at simplistix.co.uk
Wed Jul 13 04:40:38 EDT 2005


Hi All,

Ever noticed how tracebacks from ZPT are actually quite useful when 
viewed through the error_log object, but totally useless when they fail, 
say, in a unit test?

This bugged me, so I had a dig, and just discovered this cool monkey 
patch, to be inserted in any module that gets imported before an 
exception is raised:

import traceback
from zExceptions.ExceptionFormatter import format_exception
traceback.format_exception = format_exception

So now I'm mailing you lot for two reasons:

1. This makes life a lot easier when debugging failing unit tests and 
looking through entries in event.log that have tracebacks, so I thought 
I'd share it :-)

2. I wonder if there's anything bad that can happen as a result of this?

If the answer to 2 is "no", then I'm gonna wrap this up into a minute 
product...

cheers,

Chris

-- 
Simplistix - Content Management, Zope & Python Consulting
            - http://www.simplistix.co.uk


More information about the Zope mailing list