You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Clean up Python 3.4 API additions in the dis module #63577
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:
assignee='https://github.com/ncoghlan'closed_at=<Date2013-11-06.12:08:50.829>created_at=<Date2013-10-24.13:44:36.616>labels= ['release-blocker']
title='Clean up Python 3.4 API additions in the dis module'updated_at=<Date2013-11-06.12:08:50.822>user='https://github.com/ncoghlan'
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.
changed the title [-]Rename "line_offset" parameter in dis.get_instructions to "first_line"[/-][+]Clean up Python 3.4 API additions in the dis module[/+]on Nov 3, 2013
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)
Activity
ncoghlan commentedon Oct 24, 2013
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.
ncoghlan commentedon Nov 3, 2013
While working on this, I noticed a number of other issues with the dis API additions for Python 3.4 from bpo-11816. Specifically:
[-]Rename "line_offset" parameter in dis.get_instructions to "first_line"[/-][+]Clean up Python 3.4 API additions in the dis module[/+]larryhastings commentedon Nov 3, 2013
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.
ncoghlan commentedon Nov 4, 2013
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
ncoghlan commentedon Nov 4, 2013
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)
python-dev commentedon Nov 6, 2013
New changeset ce8dd299cdc4 by Nick Coghlan in branch 'default':
Close bpo-19378: address flaws in the new dis module APIs
http://hg.python.org/cpython/rev/ce8dd299cdc4