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.

Author ncoghlan
Recipients Claudiu.Popa, ncoghlan
Date 2013-10-24.13:48:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1382622486.36.0.838401814915.issue17916@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2013-10-24 13:48:06ncoghlansetrecipients: + ncoghlan, Claudiu.Popa
2013-10-24 13:48:06ncoghlansetmessageid: <1382622486.36.0.838401814915.issue17916@psf.upfronthosting.co.za>
2013-10-24 13:48:06ncoghlanlinkissue17916 messages
2013-10-24 13:48:05ncoghlancreate