[issue25538] Traceback from __exit__ method is misleading
Terry J. Reedy
report at bugs.python.org
Fri Nov 6 19:30:56 EST 2015
Terry J. Reedy added the comment:
In Martin's example, I would expect the first line of the traceback to be the file write that raised the exception, not the print that is never executed. If print were writing to a different device than the first line, the traceback would be positively misleading.
In David's example, the print executed just fine, so it should not appear in the traceback either. The replacement, if any, might be the with statement itself. The 'pseudo-line' that triggers the __exit__ call is really the dedent on the next line, but printing the whole next line would be wrong too.
----------
nosy: +terry.reedy
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25538>
_______________________________________
More information about the Python-bugs-list
mailing list