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
Clean up Python 3.4 API additions in the dis module #63577
Comments
The "line_offset" parameter in dis.get_instructions is the line number of the first line in the source file: http://docs.python.org/dev/library/dis#dis.get_instructions Calling this an offset is a little confusing, since "offset" in the dis docs almost always refers to an instruction offset. bpo-17916 is likely to make this worse, since that will probably involve new "last_offset" and "current_offset" parameters to other APIs. Renaming the parameter to "first_line" (since it sets the line number reported for the first line in the code object when iterating) should help make this less confusing. |
While working on this, I noticed a number of other issues with the dis API additions for Python 3.4 from bpo-11816. Specifically:
|
Would this be a good time for me to ask about publishing the stack effect info? I had to write my own parallel implementation of it for my assembler, so I found it irritating that Python doesn't provide it. |
I think it's a good idea in principle, but unrelated to this patch :) This one started as reworking line_offset as a more intuitive "first_line" parameter, and then testing and documenting that change proceeded to reveal a number of other issues with the 3.4 API additions :P |
There was another change implemented as part of this: trailing whitespace is now stripped from the lines emitted by the disassembler, which made it possible to simplify the tests a bit (since they no longer have to strip that whitespace themselves, they can just do normal string comparisons) I rediscovered this existing issue, since the new more comprehensive tests for correct handling of the file parameter didn't have the extra operations to strip the trailing whitespace from each line. Rather than adding it, I just fixed the dissassembler to avoid emitting it in the first place (that was a lot easier now that Instruction._disassemble was the sole place responsible for emitting each line) |
New changeset ce8dd299cdc4 by Nick Coghlan in branch 'default': |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: