[Python-Dev] Problems with GeneratorExit deriving from Exception
nnorwitz at gmail.com
Sun Dec 2 21:08:40 CET 2007
On Dec 2, 2007 11:29 AM, Chad Austin <chad at imvu.com> wrote:
> Hi Antoine,
> Antoine Pitrou wrote:
> > Hi,
> > (I was asked to forward this from the bug tracker)
> >> We have also run into problems where a task tries to "return" (yield Return())
> >> from within a try: except Exception: block. Since returning from a coroutine is
> >> roughly equivalent to "raise GeneratorExit", the exception can be caught and
> >> ignored, with the same consequences as above.
> > I may be missing something but why don't you just catch StandardError
> > instead? If I believe Python 2.5's exception hierarchy it would catch
> > anything under Exception except for GeneratorExit, StopIteration and the
> > various Warnings.
> If socket.error, xmlrpclib.Fault, httplib.HTTPException, etc. all extended
> StandardError, then we would probably be fine with that approach. But I think
> the majority of exceptions, both in the standard library and our code, extend
> Exception directly.
Note that StandardError was removed from py3k.
More information about the Python-Dev