This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Remove PyCode_New and PyCode_NewWithPosOnlyArgs
Type: behavior Stage: needs patch
Components: Versions: Python 3.11
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: corona10, da-woods, gvanrossum, vstinner
Priority: normal Keywords:

Created on 2021-09-06 22:44 by gvanrossum, last changed 2022-04-11 14:59 by admin.

Messages (10)
msg401188 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2021-09-06 22:44
This is up for grabs.

For reference, the Steering Council approved getting rid of these two C APIs without honoring the customary two-release deprecation period required by PEP 387.

For reference see This also has references to python-dev and python-committers discussions.
msg401189 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2021-09-06 22:45
PS. It would be nice to also update Cython, which is the only thing that uses these C APIs.
msg401190 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-09-06 23:17
If possible, I suggest to do in in this order:

* Fix Cython
* Publish a Cython release including the fix
* (Maybe wait a bit)
* Remove the two functions

Previously, we tried to first modified Python, and then update Cython: it went bad.

Otherwise, the following 136 popular PyPI packages will fail to build on Python 3.11:

In Fedora, we start to integrate Python 3.11 since alpha 1. In the past, the broken Cython was really annoying: many important packages failed to build, and so everything was broken. Hopefully, we can now patch Cython, and we modified most recipes building Python packages to always regenerate Cython source, to avoid such problem.
msg401191 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-09-06 23:21
I understood that these function calls shoud be replaced with:

* PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno)
* code.replace() method:
msg401192 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2021-09-06 23:24
That sounds like a good plan (note that alpha 1 will go out around Oct 4).

I left an issue for Cython:
msg401201 - (view) Author: Dong-hee Na (corona10) * (Python committer) Date: 2021-09-07 01:31
FYI, mypyc is using PyCode_New.
mypyc should be fixed not to use PyCode_New :)
msg401203 - (view) Author: Dong-hee Na (corona10) * (Python committer) Date: 2021-09-07 02:19
I sent the patch for this issue:
msg401212 - (view) Author: (da-woods) * Date: 2021-09-07 06:15
Nuitka ( - a third Python->C API compiler) also looks to use it so you might want to let them know too while you're doing the rounds on this.
msg401279 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2021-09-07 14:07
Da-woods, can you take care of that?
msg401316 - (view) Author: (da-woods) * Date: 2021-09-07 17:50
Date User Action Args
2022-04-11 14:59:49adminsetgithub: 89285
2021-09-07 17:50:52da-woodssetmessages: + msg401316
2021-09-07 14:07:50gvanrossumsetmessages: + msg401279
2021-09-07 06:15:47da-woodssetnosy: + da-woods
messages: + msg401212
2021-09-07 02:19:33corona10setmessages: + msg401203
2021-09-07 01:31:05corona10setmessages: + msg401201
2021-09-07 01:28:55corona10setnosy: + corona10
2021-09-06 23:24:35gvanrossumsetmessages: + msg401192
2021-09-06 23:21:06vstinnersetmessages: + msg401191
2021-09-06 23:17:00vstinnersetnosy: + vstinner
messages: + msg401190
2021-09-06 22:45:03gvanrossumsetmessages: + msg401189
2021-09-06 22:44:03gvanrossumcreate