Nick Coghlan <ncogh...@gmail.com> added the comment:

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)

----------
assignee: ncoghlan -> rhettinger
Added file: 
http://bugs.python.org/file23019/issue11816_get_opinfo_branch_20110824.diff

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue11816>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to