This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author martin.panter
Recipients benjamin.peterson, brett.cannon, emptysquare, gvanrossum, larry, martin.panter, ncoghlan, pitrou, serhiy.storchaka, vstinner, yselivanov
Date 2015-11-18.22:22:02
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1447885322.18.0.299336827973.issue25612@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2015-11-18 22:22:02martin.pantersetrecipients: + martin.panter, gvanrossum, brett.cannon, ncoghlan, pitrou, vstinner, larry, benjamin.peterson, serhiy.storchaka, yselivanov, emptysquare
2015-11-18 22:22:02martin.pantersetmessageid: <1447885322.18.0.299336827973.issue25612@psf.upfronthosting.co.za>
2015-11-18 22:22:02martin.panterlinkissue25612 messages
2015-11-18 22:22:02martin.pantercreate