
On 12/05/2014 03:59 PM, Stefan Behnel wrote:
Could you provide some example code that illustrates this, and mark the places where the exception is available and where it's lost?
I will try to cook up a test case, may take some time.
Is it possible that the output stream is closed (or otherwise unwritable) when your post-processing exception is raised, so that an actual IOError is raised when trying to write out the closing tags, which then shadows the original exception?
I don't close the output stream when throwing the exception. On closer inspection, the situation is slightly different than I just described: I do not know for sure if the exception is masked in the coroutine or not. Need to test. Presently, I solve the problem by catching the exception in the write method of the file-like object that lxml writes into. If I don't catch the exception there, allowing it to trickle downstream, I get an IOError in stead of the original exception. Sorry for the confusion.
I assume you're using Python 2.x, which cannot chain exceptions?
Yes, this is on Python 2.x. Thanks for your quick response!