homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Clean up Python 3.4 API additions in the dis module
Type: Stage: resolved
Components: Versions: Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: ncoghlan Nosy List: larry, ncoghlan, python-dev, rfk, rhettinger
Priority: release blocker Keywords: patch

Created on 2013年10月24日 13:44 by ncoghlan, last changed 2022年04月11日 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue19378_dis_module_fixes.diff ncoghlan, 2013年11月03日 15:03 Assorted fixes for the dis module review
Messages (6)
msg201131 - (view) Author: Alyssa Coghlan (ncoghlan) * (Python committer) Date: 2013年10月24日 13:44
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. Issue 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.
msg202028 - (view) Author: Alyssa Coghlan (ncoghlan) * (Python committer) Date: 2013年11月03日 15:03
While working on this, I noticed a number of other issues with the dis API additions for Python 3.4 from issue 11816. Specifically:
- the file output redirection API didn't work in some cases that resulted in calls to other disassembly functions
- Bytecode.show_info() replicates a bad module level API that shouldn't be perpetuated
- Bytecode.display_code() is better converted to a dis() method that returns a string rather than writing directly to an output stream
msg202053 - (view) Author: Larry Hastings (larry) * (Python committer) Date: 2013年11月03日 19:38
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.
msg202076 - (view) Author: Alyssa Coghlan (ncoghlan) * (Python committer) Date: 2013年11月04日 02:52
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
msg202077 - (view) Author: Alyssa Coghlan (ncoghlan) * (Python committer) Date: 2013年11月04日 02:56
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)
msg202261 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013年11月06日 12:08
New changeset ce8dd299cdc4 by Nick Coghlan in branch 'default':
Close #19378: address flaws in the new dis module APIs
http://hg.python.org/cpython/rev/ce8dd299cdc4 
History
Date User Action Args
2022年04月11日 14:57:52adminsetgithub: 63577
2013年11月06日 12:08:50python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg202261

resolution: fixed
stage: resolved
2013年11月04日 13:35:23ncoghlansetassignee: ncoghlan
2013年11月04日 02:56:55ncoghlansetmessages: + msg202077
2013年11月04日 02:52:24ncoghlansetmessages: + msg202076
2013年11月03日 19:38:29larrysetmessages: + msg202053
2013年11月03日 15:03:32ncoghlansetfiles: + issue19378_dis_module_fixes.diff
priority: normal -> release blocker


title: Rename "line_offset" parameter in dis.get_instructions to "first_line" -> Clean up Python 3.4 API additions in the dis module
keywords: + patch
nosy: + rhettinger, rfk, larry
versions: + Python 3.4
messages: + msg202028
2013年10月24日 13:48:06ncoghlanlinkissue17916 dependencies
2013年10月24日 13:44:36ncoghlancreate

AltStyle によって変換されたページ (->オリジナル) /