[PATCH 1 of 15] Add traceback of exceptions

Vincent Wagelaar vincent at ricardis.tudelft.nl
Wed Aug 24 17:48:50 CDT 2005


On Thursday 25 August 2005 00:20, Bryan O'Sullivan wrote:
> On Wed, 2005-08-24 at 23:49 +0200, vincent at ricardis.tudelft.nl wrote:
> > +        import traceback
> > +        req.out.write("Content-type: text/html\r\n\r\n")
> > +        traceback.print_exc(file=req.out)
> > +        req.finish()
>
> You should probably use the cgitb module instead.
>
> 	<b
hmm... simply 

import cgitb; cgitb.enable()
there is no way to hook the fastcgi filedescripter in the enable function
won't work.

After looking in the source of cgitb a possibility would be:

import traceback, cgitb
req.out.write("Content-type: text/html\r\n\r\n")
req.out.write(cgitb.html(sys.exc_info())
req.out.finish()


More information about the Mercurial mailing list