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 ron_adam
Recipients alex, belopolsky, eric.snow, jcea, meador.inge, ncoghlan, rfk, rhettinger, ron_adam
Date 2011-12-04.04:17:08
SpamBayes Score 7.9667615e-09
Marked as misclassified No
Message-id <1322972229.9.0.837162991133.issue11816@psf.upfronthosting.co.za>
In-reply-to
Content
Instead of a get_instructions() function, How about using a DisCode class that defines the API for accessing Opinfo tuples of a disassembled object.

So instead of...

    for instr in dis.bytecode_instructions(thing):
        process(instr)

You could use...

    for instr in dis.DisCode(thing):
        process(instr)

And I would like to be able to do...

    assertEqual(DisCode(thing1), DisCode(thing2))


It could also have a .dis() method that returns formatted output that matches what dis() currently prints.  That would allow tests that use dis.dis() to get rid of capturing stdout with minimal changes.

     result = DisCode(func).dis()  # return a dis compatible string.

A DisCode object also offers a nice place to put documentation for the various pieces and an overall view of the new API without getting it confused with the current dis.dis() API.

It's easier for me to remember an object with methods than several separate but related functions. (YMMV)

This is very near a version of dis I did a while back where I removed the prints and returned a list of list object from dis.dis().  The returned object had __repr__ that formatted the data so it matched the current dis output.  That made it work the same in a python shell. But I could still access and alter individual lines and fields by indexing or iterating it.  While it worked nicely, it wouldn't be backwards compatible.
History
Date User Action Args
2011-12-04 04:17:10ron_adamsetrecipients: + ron_adam, rhettinger, jcea, ncoghlan, belopolsky, alex, rfk, meador.inge, eric.snow
2011-12-04 04:17:09ron_adamsetmessageid: <1322972229.9.0.837162991133.issue11816@psf.upfronthosting.co.za>
2011-12-04 04:17:09ron_adamlinkissue11816 messages
2011-12-04 04:17:08ron_adamcreate