Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Implement yield-from in Python 2.x as a macro #686
It looks fine to me, though it is incomplete IIRC. If exceptions are called, they should be able to be propagated via the coroutine's .throw() method, correct? I don't think this happens here?
https://www.python.org/dev/peps/pep-0380/#formal-semantics gives a sense of how this works I think.
We could merge this as-is, but it would need to be documented that this functionality is not included.
@paultag is right and I am wrong. Exception handling in the yield-from macro works as expected. As such I merged @paultag's branch. I also added a test to prove that paultag is right, so we know for eternity that exception handling is indeed working right. (I also fixed some indentation on paultag's test while I was at it!)
Nice work @paultag! I'm glad I was wrong, and impressed by the conciseness of the implementation!