stackprinter icon indicating copy to clipboard operation
stackprinter copied to clipboard

Catch wrong linenos

Open cknd opened this issue 3 years ago • 0 comments

Catch an (crashing #45 ) edge case where the frame's current line numer is wrong, or the discoverd line number where the frame's code block starts is. This looks like a python bug or an inspect.getsource bug -- OR a getsource bug that is ultimately a python bug, because inspect just uses frame.f_code.co_firstlineno (= the frame's own reported beginning of its code block), and I can't imagine a situation where that can legitimately not contain frame.f_lineno.

I deal with this here by showing a warning in-band that the line number can't be 100% trusted, while also moving the active line shown down to the first available source line.

(Not completely happy with that solution, of course)

cknd avatar Mar 16 '21 21:03 cknd