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.
Created on 2013年05月06日 12:54 by ncoghlan, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| dis.patch | Claudiu.Popa, 2013年08月21日 11:46 | review | ||
| dis_tb.patch | Claudiu.Popa, 2013年10月24日 18:02 | review | ||
| dis_tb_3.patch | Claudiu.Popa, 2013年11月21日 21:07 | review | ||
| Messages (10) | |||
|---|---|---|---|
| msg188528 - (view) | Author: Alyssa Coghlan (ncoghlan) * (Python committer) | Date: 2013年05月06日 12:54 | |
Issue 11816 adds a new dis.Bytecode API that replaces most of the dis functions, but doesn't cover dis.distb. A dis.Bytecode.from_tb class method, or a TracebackBytecode subclass to handle that use case may be desirable. |
|||
| msg195776 - (view) | Author: PCManticore (Claudiu.Popa) * (Python triager) | Date: 2013年08月21日 11:46 | |
Here's a basic patch, using a classmethod. It doesn't support the full distb API (if the traceback is not given, try to retrieve the last one), because Bytecode.from_tb() looks pretty weird. |
|||
| msg201124 - (view) | Author: PCManticore (Claudiu.Popa) * (Python triager) | Date: 2013年10月24日 13:14 | |
Nick, could you review this, please? It would be nice if we can flesh it out and add it to 3.4. |
|||
| msg201133 - (view) | Author: Alyssa Coghlan (ncoghlan) * (Python committer) | Date: 2013年10月24日 13:48 | |
It's not quite that simple - the instruction responsible for the exception also needs to be recorded, and Bytecode doesn't currently allow for that (look at the way the "lasti" arg to disassemble is used in disttb, and then how that gets passed to the "mark_as_current" flag in Instruction._disassemble by _disassemble_bytes). So, on reflection, I think a TracebackBytecode class may be a better idea, exposing "bytecode" and "last_offset" attributes. Rather than iteration just producing instructions, it would produce (instruction, is_current) 2-tuples, and display_code would call through to "self.bytecode.display_code(self.last_offset)" (there would be no show_info() or info() methods on TracebackBytecode). Bytecode.display_code would gain a new "current_offset" parameter, which it would pass through to _disassemble_bytes as the "lasti" parameter. Reviewing this also made me realise "line_offset" in dis.get_instructions is misnamed - see issue 19378. |
|||
| msg201160 - (view) | Author: PCManticore (Claudiu.Popa) * (Python triager) | Date: 2013年10月24日 18:02 | |
Here's the updated version according to your comments. Because there is no need for show_info() and info(), the current class is not a subclass of Bytecode (as I implied from your first message). After issue19378 is fixed, we could change the line_offset with something else in TracebackBytecode.__iter__. |
|||
| msg203619 - (view) | Author: PCManticore (Claudiu.Popa) * (Python triager) | Date: 2013年11月21日 12:04 | |
Nick, what's your opinion on my latest patch? |
|||
| msg203623 - (view) | Author: Alyssa Coghlan (ncoghlan) * (Python committer) | Date: 2013年11月21日 12:18 | |
My apologies for not reviewing this earlier, it's been a somewhat hectic month. Thanks for pinging the ticket while there's still a chance to get this into 3.4 :) After my last round of updates to dis.Bytecode removed the potential for confusion between line_offset and current_offset, I'm back to thinking it makes more sense to build this feature directly into dis.Bytecode rather than using a separate type. 1. Add the "current_offset" attribute to dis.Bytecode 2. Add a "current_offset" parameter to dis.Bytecode.__init__ (defaulting to None) 3. In dis.Bytecode.dis(), pass "current_offset" as the value for "lasti" in the call to _disassemble_bytes (except for passing -1 if current_offset is None) 4. Add a "from_traceback()" class method that sets current_offset appropriately in the call to build the instance |
|||
| msg203671 - (view) | Author: PCManticore (Claudiu.Popa) * (Python triager) | Date: 2013年11月21日 21:07 | |
Thanks, Nick! Attached the new version, I hope that I did it right this time. |
|||
| msg203775 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2013年11月22日 14:57 | |
New changeset d71251d9fbbe by Nick Coghlan in branch 'default': Close #17916: dis.Bytecode based replacement for distb http://hg.python.org/cpython/rev/d71251d9fbbe |
|||
| msg203776 - (view) | Author: Alyssa Coghlan (ncoghlan) * (Python committer) | Date: 2013年11月22日 14:58 | |
Thank you for the patch! It's nice to have this included for the initial general availability of the new disassembly API :) |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:45 | admin | set | github: 62116 |
| 2013年11月22日 14:58:24 | ncoghlan | set | messages: + msg203776 |
| 2013年11月22日 14:57:23 | python-dev | set | status: open -> closed nosy: + python-dev messages: + msg203775 resolution: fixed stage: needs patch -> resolved |
| 2013年11月22日 14:44:03 | ncoghlan | set | assignee: ncoghlan |
| 2013年11月21日 21:07:04 | Claudiu.Popa | set | files:
+ dis_tb_3.patch messages: + msg203671 |
| 2013年11月21日 12:18:44 | ncoghlan | set | messages: + msg203623 |
| 2013年11月21日 12:04:58 | Claudiu.Popa | set | messages: + msg203619 |
| 2013年10月24日 18:02:45 | Claudiu.Popa | set | files:
+ dis_tb.patch messages: + msg201160 |
| 2013年10月24日 13:48:06 | ncoghlan | set | dependencies:
+ Clean up Python 3.4 API additions in the dis module messages: + msg201133 |
| 2013年10月24日 13:14:58 | Claudiu.Popa | set | messages: + msg201124 |
| 2013年08月21日 11:46:05 | Claudiu.Popa | set | files:
+ dis.patch nosy: + Claudiu.Popa messages: + msg195776 keywords: + patch |
| 2013年05月06日 12:54:32 | ncoghlan | set | dependencies: + Refactor the dis module to provide better building blocks for bytecode analysis |
| 2013年05月06日 12:54:24 | ncoghlan | create | |