Skip to content
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

Use Py_SET_TYPE() and Py_SET_SIZE() for Python 3.10 #109

Merged
merged 1 commit into from
Dec 18, 2020
Merged

Use Py_SET_TYPE() and Py_SET_SIZE() for Python 3.10 #109

merged 1 commit into from
Dec 18, 2020

Conversation

vstinner
Copy link
Contributor

@vstinner vstinner commented Dec 9, 2020

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.

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.
@vstinner
Copy link
Contributor Author

vstinner commented Dec 9, 2020

Python 3.10 requires to use Py_SET_TYPE() and Py_SET_SIZE() functions
to set an object type or size.

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.

@vstinner
Copy link
Contributor Author

vstinner commented Dec 9, 2020

I ran manually the test suite with my patch and it pass on Fedora 33 with Python 3.10.0a2:

python3.10 -m venv ENV
ENV/bin/python setup.py install
ENV/bin/python bitarray/test_bitarray.py 

@vstinner
Copy link
Contributor Author

vstinner commented Dec 9, 2020

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).

@ilanschnell
Copy link
Owner

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?

@vstinner
Copy link
Contributor Author

As I wrote, the change has been reverted in Python 3.10a3, but it may be done again in a future Python version.

@vstinner
Copy link
Contributor Author

See Py_TYPE() documentation:

The Py_SET_SIZE() function must be used to set an object size.

https://docs.python.org/dev/c-api/structures.html#c.Py_SIZE

@ilanschnell ilanschnell merged commit a0cca9f into ilanschnell:master Dec 18, 2020
@vstinner vstinner deleted the py_set_size branch December 18, 2020 01:01
@vstinner
Copy link
Contributor Author

Thanks :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants