-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
dis.dis()
reports line numbers where there are none.
#107932
Comments
I've submitted this as a "bug", but it could be argued it is a behavior change, so I think it shouldn't be backported. @iritkatriel thoughts? |
I think I'd call it a bug and backport. |
Are bytecodes that do not map back to any source line intended behavior? Older versions of python seem to not generate the bytecode that has no source line for this fragment (tested on 3.10) Was working on a PR for this but most of dis.py makes the assumption of every bytecode has a source line so the behavior change is getting vague and messy quickly. For example findlinestarts() ignores line=None so dis() (and many of the other exported functions that depend on it) group these lines in with the previous block of bytecodes. I'm happy to keep working on the patch but looking for some assurance the actual "bug" is disassembly related rather than in the bytecode generator before continuing further. |
It is definitely intentional that the compiler can generate instructions that are "synthetic" and don't map directly to any line number in the source. And yes, this is a change in recent Python versions, that didn't used to be possible. So it's not too surprising that |
Adjust expected instruction trace
It broke the tests. |
They will be fixed by #108478 @serhiy-storchaka |
now merged |
Take this example function from #107901:
dis.dis
produces the following output:Which has incorrect line numbers.
The issue is not that the line numbers are wrong, but that you can't tell from the
dis
output.The whole point of
dis
is show what is going on at the bytecode level, so it is failing if it gives wrong line numbers.The actual line numbers can be see from
co_lines()
The correct output should be:
Linked PRs
The text was updated successfully, but these errors were encountered: