dis.disassemble_string(), called by dis.dis("some-bytecode-string"), still relies on the dead SET_LINENO opcode. I'll propose a patch for this at some later time.
Logged In: YES user_id=4771 ah well. I didn't realize that disassemble_string() never tried to *display* line numbers. It only detects SET_LINENO so that it can write a nice blank line before it. Attached a patch that removes this behavior (no longer possible in a function that doesn't have access to a co_lnotab). I'll submit another more constructive patch anyway, in which I try to factor out the subtle decoding algorithm for co_lnotabs into an easy-to-use generator.
Logged In: YES user_id=4771 Here is a patch with a separate generator function that enumerates all (offset, lineno) pairs, as they where in the compiler before they got obfuscated into lnotab. For simplicity, disassemble() just turns them into a dict, so it didn't really have to be a generator at all, but it is just nicer this way. Maybe pdb could use it too.
Logged In: YES user_id=4771 Do we want findlinestarts() to be added to the public interface of dis? I think it is a generally useful tool (e.g. it could be used in trace.py too, though I don't understand trace.py well enough to know if the easy patch does exactly what is expected). I can write a doc patch if the answer is yes.
Logged In: YES user_id=4771 findlinestarts() not documented. Its docstring should be enough to interest people that want to play with co_lnotab. Checked in: Lib/dis.py (rev: 1.47)