On 14 April 2016 at 08:26, Victor Stinner email@example.com wrote:
2016-04-14 0:11 GMT+02:00 Ryan Gonzalez firstname.lastname@example.org:
So code that depends on iterating through bytecode via HAS_ARG is going to break...
Sure. This change is backward incompatible for applications parsing bytecode in C or Python. That's why the patch also has to update the dis module.
I don't see how you plan to keep the backwad compatibility, since the argument size changed from 2 bytes to 1 byte. You must update your code (written in C or Python or whatever).
Hopefully, the dis was enhanced in Python 3.4: get_instructions() now gives nice Instructon objects rather than only pure text output.
FYI I wrote my own library to decode and decode bytecode. It provides abstract bytecode objects to easily modify bytecode: https://bytecode.readthedocs.org/
I suggest to use such library (or simply the dis module for simple needs) if you have to handle bytecode, rather than writing your own code.
I know a few other projects which handle directly bytecode:
IHMO it's not a big deal to update these projects for the future Python 3.6. I can even help them to support the new bytecode format.
We've also had previous discussions on adding a "minimum viable bytecode editing" API to the standard library, and updating these third party modules to support wordcode instead of bytecode could provide a good use-case-driven opportunity for defining that (i.e. it wouldn't be about providing an end user facing API directly, but rather about letting CPython take care of the bookkeeping details for things like lnotab and sorting out jump targets).