Message254858
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. |
|
Date |
User |
Action |
Args |
2015-11-18 22:22:02 | martin.panter | set | recipients:
+ martin.panter, gvanrossum, brett.cannon, ncoghlan, pitrou, vstinner, larry, benjamin.peterson, serhiy.storchaka, yselivanov, emptysquare |
2015-11-18 22:22:02 | martin.panter | set | messageid: <1447885322.18.0.299336827973.issue25612@psf.upfronthosting.co.za> |
2015-11-18 22:22:02 | martin.panter | link | issue25612 messages |
2015-11-18 22:22:02 | martin.panter | create | |
|