Nick Coghlan wrote:
Jacob Holm wrote:
The problem is that any exception thrown into inner is converted to a GeneratorReturn, which is then swallowed by the yield-from instead of being reraised.
That actually only happens if inner *catches and suppresses* the thrown in exception. Having a return in the finally clause like in my example is sufficient to suppress the exception.
Otherwise throw() will reraise the original exception automatically:
I am not sure what your point is. Yes, this is a corner case. I am trying to make sure we have the corner cases working as well. In the example I gave I think it was pretty clear what should happen according to the inlining principle. The suppression of the initial exception is an accidental side effect of the refactoring. It looks to me like using the __cause__ attribute on the GeneratorReturn will allow us to reraise the exception. This seems like exactly the kind of thing that the __cause__ and __context__ attributes from PEP 3134 was designed for. - Jacob