[issue25612] nested try..excepts don't work correctly for generators

Martin Panter report at bugs.python.org
Tue Nov 17 16:36:40 EST 2015


Martin Panter added the comment:

Regarding the second bug, did you consider that the exception thrown to the generator can already have __context__ set?

try:
    try: raise ValueError("Context outside of generator")
    except ValueError as ex: raise SubError() from ex
except SubError as ex:
    coro.throw(ex)  # ex.__context__ is a ValueError

I guess either one context could trump the other, or we could to follow the chain of contexts and append the other chain at the end. Both these ideas seem a bit ugly though.

----------
nosy: +martin.panter

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25612>
_______________________________________


More information about the Python-bugs-list mailing list