06.06.21 06:48, Guido van Rossum пише:
On Fri, Jun 4, 2021 at 6:15 AM Victor Stinner <firstname.lastname@example.org mailto:email@example.com> wrote: If possible, I would prefer to make PyThreadState, PyCodeObject and other structures opaque, and only go through getter and setter functions ;-) PyCode_New() is another problem :-/ The PEP 570 first changed it to add a new parameter. It broke Cython and other projects. The change was reverted, and PyCode_NewWithPosOnlyArgs() was added. The lesson is that it's possible to change PyCodeObject without breaking PyCode_New() (which handles the "backward compatibility" for you).
I'm afraid that won't always be possible though. At some point there just may not be a valid meaning for the original PyCode_New() call. It was easy in the case of positional arguments (by default don't have any) but it may not always be that simple, and we shouldn't make guarantees here.
We have already reached this limit. In 3.11 the code object needs a table of exception handlers. Only simplest code which do not contain any "try" or "with" can now be created with old PyCode_New() and PyCode_NewWithPosOnlyArgs().