[New-bugs-announce] [issue25538] Traceback from __exit__ method is misleading
R. David Murray
report at bugs.python.org
Mon Nov 2 18:08:03 EST 2015
New submission from R. David Murray:
This is at least the second time that I've wasted a bunch of debugging time being mislead by the traceback from __exit__. Perhaps I will remember from now on, but...I wonder if it would be possible/practical to improve the situation. The problem is that in the traceback printed when __exit__ throws an error, the source line printed before the source line from inside the __exit__ is the last line of the 'with' block. I kept staring at that line trying to figure out how the exception could possibly be getting raised from that line...which of course it wasn't really, it was the "line" in between that one and the next one, a psuedo-line representing the exit from the block.
I don't know if it would be worth the effort that would be required to somehow clarify this in the traceback (I'm not even sure what that would *look* like...maybe the first line of the with block instead?), but I thought I'd raise the issue to see if anyone had any clever ideas.
(Hopefully I haven't done this before...I tried searching for similar issues and didn't find anything.)
title: Traceback from __exit__ method is misleading
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce