Use Py_SET_TYPE() and Py_SET_SIZE() for Python 3.10#109
Use Py_SET_TYPE() and Py_SET_SIZE() for Python 3.10#109ilanschnell merged 1 commit intoilanschnell:masterfrom vstinner:py_set_size
Conversation
Python 3.10 requires to use Py_SET_TYPE() and Py_SET_SIZE() functions to set an object type or size. Add a copy of the compatibility pythoncapi_compat.h header file which provides Py_SET_TYPE() and Py_SET_SIZE() to old Python versions: these functions were added to Python 3.9.
See https://bugs.python.org/issue39573#msg381365 for the context: the incompatible Python 3.10 change was reverted to give time to C extension modules maintainers to port their extension. So here is such change to support Python 3.10 without losing support for old Python versions. See also https://github.com/pythoncapi/pythoncapi_compat : I used upgrade_python_capi.py script to create this PR, and copied the pythoncapi_compat.h header file from there. |
|
I ran manually the test suite with my patch and it pass on Fedora 33 with Python 3.10.0a2: |
|
Without this change, it was not possible to build bitarray on Python 3.10.0a2 (again, the C API incompatible change was reverted in Python 3.10.a3). |
|
Thank you for this PR! I've tested master with the 3.10.a3 release (which reverted this incompatible change), and all works fine. Is this the incompatible C API change expected to be added again in the 3.10 final release? |
|
As I wrote, the change has been reverted in Python 3.10a3, but it may be done again in a future Python version. |
|
See Py_TYPE() documentation:
|
|
Thanks :-) |
Python 3.10 requires to use Py_SET_TYPE() and Py_SET_SIZE() functions
to set an object type or size.
Add a copy of the compatibility pythoncapi_compat.h header file which
provides Py_SET_TYPE() and Py_SET_SIZE() to old Python versions:
these functions were added to Python 3.9.