[Python-bugs-list] [ python-Bugs-811294 ] dis.disassemble_string() broken

SourceForge.net noreply at sourceforge.net
Fri Sep 26 07:07:32 EDT 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: Open
Resolution: None
Priority: 5
Submitted By: Armin Rigo (arigo)
Assigned to: Raymond Hettinger (rhettinger)
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-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