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.)

----------
messages: 253949
nosy: r.david.murray
priority: normal
severity: normal
status: open
title: Traceback from __exit__ method is misleading

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25538>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to