-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Port mypyc to Python 3.11: use Py_SET_SIZE() #11652
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
Conversation
"Py_TYPE(t) = metaclass;" fails with a compiler error on Python 3.11: * https://docs.python.org/dev/whatsnew/3.11.html#c-api-changes * https://docs.python.org/dev/c-api/structures.html#c.Py_TYPE * Replace "Py_TYPE(t) = metaclass;" with "Py_SET_TYPE(t, metaclass);" * Replace "Py_SIZE(self) = newsize;" with "Py_SET_SIZE(self, newsize);" * Add a copy of pythoncapi_compat.h header to add Py_SET_TYPE() and Py_SET_SIZE() functions to Python 3.8 and older: https://github.com/pythoncapi/pythoncapi_compat
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. |
Right now, I cannot run
|
Issue already reported upstream: python/typed_ast#167 |
I also got build issues when trying to install the lxml dependency. Cython 0.29.24 is not compatible with Python 3.11 yet: the cython/cython@e138a84 change (part of the 0.29.x branch) is needed, but there is no Cython 0.29.x release including this change yet. I asked for a Cython release at cython/cython#4465 |
This seems great, thank you for the PR. I'm not too worried about not running the 3.11 tests. |
Thanks for the merge ;-) |
"Py_TYPE(t) = metaclass;" fails with a compiler error on Python 3.11: * https://docs.python.org/dev/whatsnew/3.11.html#c-api-changes * https://docs.python.org/dev/c-api/structures.html#c.Py_TYPE * Replace "Py_TYPE(t) = metaclass;" with "Py_SET_TYPE(t, metaclass);" * Replace "Py_SIZE(self) = newsize;" with "Py_SET_SIZE(self, newsize);" * Add a copy of pythoncapi_compat.h header to add Py_SET_TYPE() and Py_SET_SIZE() functions to Python 3.8 and older: https://github.com/pythoncapi/pythoncapi_compat
"Py_TYPE(t) = metaclass;" fails with a compiler error on Python 3.11:
https://docs.python.org/dev/whatsnew/3.11.html#c-api-changes
https://docs.python.org/dev/c-api/structures.html#c.Py_TYPE
Replace "Py_TYPE(t) = metaclass;" with "Py_SET_TYPE(t, metaclass);"
Replace "Py_SIZE(self) = newsize;" with "Py_SET_SIZE(self, newsize);"
Add a copy of pythoncapi_compat.h header to add Py_SET_TYPE() and
Py_SET_SIZE() functions to Python 3.8 and older:
https://github.com/pythoncapi/pythoncapi_compat
Have you read the Contributing Guidelines?
(Once you have, delete this section. If you leave it in, your PR may be closed without action.)
Description
(Explain how this PR changes mypy.)
Test Plan
(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work.)