[issue37647] Wrong lineno in traceback when formatting strings with % and multilines

Serhiy Storchaka report at bugs.python.org
Mon Jul 22 03:28:56 EDT 2019


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

Line 9 is not where the error actually happened. The exception is raised not when you call Z(), but when you implicitly call Z.__str__() when evaluate the % operator.

In Python 3.8 the traceback points to the start of the subexpression that raises an exception.

So this issue has been fixed in 3.8. The fix was not backported to 3.7 because it is a large change which affects other code that traces execution or analyses tracebacks (e.g. coverage.py).

----------
resolution:  -> out of date
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37647>
_______________________________________


More information about the Python-bugs-list mailing list