Skip to content

gh-136190: dis.py: No line number in case of an artificial bytecode instruction #136923

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

Closed
wants to merge 2 commits into from

Conversation

dszon
Copy link

@dszon dszon commented Jul 21, 2025

This is a proposal to fix gh-136190 (at least in dis).

If the compiler returns no line number in case of an artificial bytecode instruction, then we show the last known line number.

…ode instruction, then we show the last known line number.
@bedevere-app
Copy link

bedevere-app bot commented Jul 21, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@StanFromIreland StanFromIreland changed the title dis.py: No line number in case of an artificial bytecode instruction gh-136190: dis.py: No line number in case of an artificial bytecode instruction Jul 21, 2025
@bedevere-app
Copy link

bedevere-app bot commented Jul 21, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@StanFromIreland
Copy link
Member

In the future, please add the issue number to the title (I have edited this prs title to the correct format) so that it can be automatically linked.

@StanFromIreland StanFromIreland marked this pull request as draft July 21, 2025 10:16
Copy link
Member

@StanFromIreland StanFromIreland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Familiarise yourself with the current layout of stdlib tests, and move your tests there. They should be updated to use unittest like the existing tests, and cleaned up, removing commented out tests.

@nedbat
Copy link
Member

nedbat commented Jul 21, 2025

I'm not sure it's useful to change dis to supply the missing number. I would rather that the deeper information used by other tools (like coverage.py) was more correct, and that dis was a relatively shallow viewer of that data.

For example, you said on the issue: "disadvantage: other inspection tool would then still show no line number".

@picnixz
Copy link
Member

picnixz commented Jul 21, 2025

I agree. I would rather fix the location on the interpreter's side rather than in dis.

@dszon
Copy link
Author

dszon commented Jul 21, 2025

So let's close this PR.

@dszon dszon closed this Jul 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3.14 is missing a bytecode line number for one-line conditionals
4 participants