Martin Panter added the comment:

I was making an analogy between how the “raise” statement works, and how the 
throw() method could work. In this example, there are three exception objects 
(MainError, SubError, and ValueError). I was suggesting that it is okay for the 
context to be set to the MainError instance, because that is how the analogous 
version using a “raise” statement works.

def main():
    try:
        raise MainError("Context inside generator")
    except MainError:
        yield  # __context__ could be changed to MainError

coro = main()
coro.send(None)
try:
    try: raise ValueError("Context outside of generator")
    except ValueError: raise SubError()
except SubError as ex:
    coro.throw(ex)  # __context__ is ValueError

# raise analogy:

try:
    try: raise ValueError("Context outside of generator")
    except ValueError as ex: raise SubError()
except SubError as ex:
    saved = ex  # __context__ is ValueError

try:
    raise MainError("Context inside generator")
except MainError:
    raise saved  # Changes __context__ to MainError

===

Sorry I’m not really familiar with the code to quickly propose a patch or 
review your change though.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25612>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to