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 ncoghlan
Recipients alex, belopolsky, jcea, ncoghlan, rfk, rhettinger
Date 2011-08-23.14:50:45
SpamBayes Score 1.9153013e-12
Marked as misclassified No
Message-id <1314111049.77.0.25326987454.issue11816@psf.upfronthosting.co.za>
In-reply-to
Content
The diff generator didn't work - I've uploaded the current patch manually to make it easier to review than it is in my bitbucket repo.

I just noticed there's a missing element in the docs patch at the moment - to make testing easier, Ryan added a 'file' argument to the various print-based dis functions so the output can easily be captured in a StringIO object. The docs updates don't currently reflect that, they only cover the OpInfo and get_opinfo additions (along with a clarification of the dis module's slightly odd use of the term 'free').

Aside from that, the core concept of the patch is pretty simple:
- add dis.OpInfo and dis.get_opinfo() to make it easier to walk the bytecode programmatically
- eliminate a lot of the logic duplication inside dis by refactoring more of the operations to internally rely on get_opinfo()
- add a new test.bytecode_helper.BytecodeTestCase with some convenient assertions for checking code generation
- update test_peepholer to be independent of the disassembly formatting details
- add tests for the new features to test_dis (but keep the old detailed formatting tests)

One potential criticism is the complexity of the 'expected output' for the new OpInfoTestCase, but it seemed worth it to vet the way the new code handles several cases. The programmatic nature makes the opcode sequences much easier to read and maintain than the corresponding formatted output tests would have been.

These new tests also cover an error that the previous incarnation of the test suite missed completely (I had a bug at one point where I had incorrectly omitted the second half of the list of cell names - there was no test to check that the disassembler handled references to such names correctly)
History
Date User Action Args
2011-08-23 14:50:51ncoghlansetrecipients: + ncoghlan, rhettinger, jcea, belopolsky, alex, rfk
2011-08-23 14:50:49ncoghlansetmessageid: <1314111049.77.0.25326987454.issue11816@psf.upfronthosting.co.za>
2011-08-23 14:50:49ncoghlanlinkissue11816 messages
2011-08-23 14:50:48ncoghlancreate