Skip to content

Conversation

@andreas-loos-zon
Copy link

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.

@andreas-loos-zon
Copy link
Author

So let's close this PR.

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