Author ncoghlan
Recipients Claudiu.Popa, ncoghlan
Date 2013-10-24.13:48:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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.
Date User Action Args
2013-10-24 13:48:06ncoghlansetrecipients: + ncoghlan, Claudiu.Popa
2013-10-24 13:48:06ncoghlansetmessageid: <>
2013-10-24 13:48:06ncoghlanlinkissue17916 messages
2013-10-24 13:48:05ncoghlancreate