[Python-bugs-list] [ python-Bugs-811294 ] dis.disassemble_string()
broken
SourceForge.net
noreply at sourceforge.net
Tue Oct 28 07:17:49 EST 2003
Bugs item #811294, was opened at 2003-09-23 17:23
Message generated for change (Comment added) made by arigo
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=811294&group_id=5470
Category: Python Library
Group: Python 2.3
>Status: Closed
Resolution: Accepted
Priority: 5
Submitted By: Armin Rigo (arigo)
Assigned to: Armin Rigo (arigo)
Summary: dis.disassemble_string() broken
Initial Comment:
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.
----------------------------------------------------------------------
>Comment By: Armin Rigo (arigo)
Date: 2003-10-28 12:17
Message:
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)
----------------------------------------------------------------------
Comment By: Armin Rigo (arigo)
Date: 2003-10-16 13:16
Message:
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.
----------------------------------------------------------------------
Comment By: Michael Hudson (mwh)
Date: 2003-10-16 12:55
Message:
Logged In: YES
user_id=6656
I think I trust Armin on stuff like this
----------------------------------------------------------------------
Comment By: Armin Rigo (arigo)
Date: 2003-09-26 11:07
Message:
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.
----------------------------------------------------------------------
Comment By: Armin Rigo (arigo)
Date: 2003-09-26 10:20
Message:
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.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=811294&group_id=5470
More information about the Python-bugs-list
mailing list