Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch wrong linenos #46

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Catch wrong linenos #46

wants to merge 3 commits into from

Conversation

cknd
Copy link
Owner

@cknd cknd commented Mar 16, 2021

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 cknd force-pushed the catch_wrong_linenos branch from d21639c to 6d94357 Compare March 16, 2021 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant