bytecode icon indicating copy to clipboard operation
bytecode copied to clipboard

Python 3.11 support

Open fabioz opened this issue 3 years ago • 5 comments

Now that Python 3.11 is in beta (and should have no new features), are there plans to support Python 3.11?

fabioz avatar May 26 '22 19:05 fabioz

Yes but I plan to work on it at one point by my current bandwidth for OSS is really low. So if you have the inclination to start something feel free to do so.

MatthieuDartiailh avatar May 26 '22 19:05 MatthieuDartiailh

I am going to start working on this slowly and post here about my progress.

The first topic I looked into is the new exception table feature. Basically it means try except are now really represented at the bytecode level as instructions but only in the table. At the ConcreteBytecode level, I think that simply having a human readable version of the format describe in https://github.com/python/cpython/blob/main/Objects/exception_handling_notes.txt is properly the right abstraction.

At the Bytecode and CFG level the story is a bit different. First we will use labels to indicate jump target as for any other jump. However I believe it would make sense to also have pseudo-instruction delineating the block in which an exception can be caught. At the Bytecode level having an entry and exit marker is relatively easy for the CFG it may be a bit more involved and I do not have a clear idea yet of what things are going to look like. Any opinion is welcome as to how to approach this new design.

MatthieuDartiailh avatar Jun 28 '22 07:06 MatthieuDartiailh

Is it possible to create an exception table object from Python?

First we will use labels to indicate jump target as for any other jump

Makes sense. Perhaps their contructors can take the target label as an identifier for the exception "block".

P403n1x87 avatar Jun 28 '22 08:06 P403n1x87

The exception table is just a bunch of bytes as described in the linked file. So yes we will be able to create it from Python.

Regarding you second point, yes the pseudo instruction will take the exception handling block label as a target.

MatthieuDartiailh avatar Jun 28 '22 09:06 MatthieuDartiailh

The exception table is just a bunch of bytes as described in the linked file. So yes we will be able to create it from Python.

Ah ok, that's just a bytes object now: https://github.com/python/cpython/blob/c485ec014ce174bb3f5ae948151dc40e0f6d5f7f/Objects/codeobject.c#L249

P403n1x87 avatar Jun 28 '22 13:06 P403n1x87