MatthieuDartiailh / bytecode

Python module to modify bytecode
https://bytecode.readthedocs.io/
MIT License
302 stars 38 forks source link

Add an instructions argument to ConcreteBytecode, and validate its value #11

Closed eric-wieser closed 7 years ago

eric-wieser commented 8 years ago

Also adds validation to Bytecode

vstinner commented 8 years ago

I dislke the current code to validate instructions. The validation is delayed when you iterate on instructions. I would prefer to raise an error on .append(123) for example.

An option would be to modify InstrList to inherit from abc.MutableSequence instead of list, and implement the ABC using a private list. setitem() and insert() would validate that added items are instructions.

eric-wieser commented 8 years ago

Ok, updated with those changes.

eric-wieser commented 7 years ago

Aside from the abc.MutableSequence change, which would probably do better as a new PR building on this, is this good to merge?