-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Port to Python 3.11: use Py_SET_SIZE() #70
Port to Python 3.11: use Py_SET_SIZE() #70
Conversation
On Python 3.11, "Py_SIZE(result) = cSize;" fails with a compiler error. Since Python 3.9, Py_SET_SIZE() must be used instead: * https://docs.python.org/dev/whatsnew/3.11.html#c-api-changes * https://docs.python.org/dev/c-api/structures.html#c.Py_SIZE Add a copy of the pythoncapi_compat.h header file to get Py_SET_SIZE() on Python 3.8 and older: https://github.com/pythoncapi/pythoncapi_compat
The build error:
I'm the author of the Py_SIZE() change in Python 3.11 :-) It has been approved by the Steering Council: python/steering-council#79 I'm also working on a PEP which changes other macros and explains the rationale for the Py_SIZE() change, see: https://www.python.org/dev/peps/pep-0674/ Moreover, I'm the author of the pythoncapi_compat project and its pythoncapi_compat.h header file: https://github.com/pythoncapi/pythoncapi_compat I'm trying to propose it as a standard way to support multiple Python versions with a single C code base. The header provides new C API functions on old Python versions. |
Test with the development branch of Python 3.11:
|
Did you check it with python versions 2.7, 3.4-3.10 too? |
I tested manually the following versions (thanks Fedora for providing a wide range of Python versions!):
=> All builds and tests passed successfully! pythoncapi_compat.h is compatible with Python 2.7: it has been tested on Windows with Visual Studio and Python 2.7. Mercurial uses it and Mercurial is still supporting Python 2.7 on Windows ;-) By the way, the
Using tox would avoid me to have to create the virtual environment and run Python manually for each Python version :-D |
Good. Thanks. |
On Python 3.11, "Py_SIZE(result) = cSize;" fails with a compiler
error. Since Python 3.9, Py_SET_SIZE() must be used instead:
Add a copy of the pythoncapi_compat.h header file to get
Py_SET_SIZE() on Python 3.8 and older:
https://github.com/pythoncapi/pythoncapi_compat