Extreme Yaro weirdness

Ron Garret rNOSPAMon at flownet.com
Mon Feb 2 11:10:19 EST 2009


In article <mailman.8612.1233589195.3487.python-list at python.org>,
 "Gabriel Genellina" <gagsl-py2 at yahoo.com.ar> wrote:

> En Mon, 02 Feb 2009 06:59:16 -0200, Ron Garret <rNOSPAMon at flownet.com>  
> escribió:
> 
> > I'm running the following WSGI app under Yaro:
> >
> > def error(req):
> >   try:
> >     req.non_existent_key
> >   except:
> >     try:
> >       return cgitb.html(sys.exc_info())
> >     except:
> >       return 'foo'
> >
> > The result of running this is 'foo'.  In other words, the reference to
> > the non-existent key generates an exception as expected, but then the
> > generation of the traceback generates ANOTHER exception, which I would
> > not have expected.  If I add another TRY/EXCEPT block to capture this
> > exception, the result is attached at the bottom of this message.
> 
> Unqualified excepts are evil -- see this recent post (mine)
> http://groups.google.com/group/comp.lang.python/msg/05e822f694b6421c
> 
> But in this case you hit a known bug in cgitb - see  
> http://bugs.python.org/issue4643 for a solution.

Aha!  Thank you!  That explains everything, except this:  why does the 
problem go away when I run under wsgiref and capture the request in a 
global variable?

Feel free to treat that as a rhetorical question :)

rg



More information about the Python-list mailing list