-
-
Notifications
You must be signed in to change notification settings - Fork 29
Description
In Python 3.11.0a1, the Py_TYPE macro was changed to a function, meaning that it cannot be used as a r-value (i.e. assignment target). All C code of the forms:
Py_TYPE(obj) = new_type;
obj->ob_type = new_type;
must be converted to
Py_SET_TYPE(obj, new_type);
This is documented in What's New in Python 3.11
The Py_SET_TYPE function was added in Python 3.9.
This change breaks existing code (though many popular projects have already been adapted in the 3.9-3.10 development window).
The change did not follow the process in PEP 387 -- Backwards Compatibility Policy, which calls for a warning for at least two releases before things break. Unfortunately, it is not feasible to only emit a warning when the macro is used as an assignment target.
The reasons for the change are given in a thread on capi-sig, specifically:
I'm not the best person to ask for this exception, as I disagree with making the change now. I believe that:
- the experiments this allows can be run with the patch as part of the experiment;
- third-party extensions needed to validate the experiments can be changed, and they'll usually accept patches if we just document that using
Py_TYPEas r-value is deprecated; - for third parties, making the change will be easier after 3.8 is EOL and
Py_SET_TYPEis in all supported Python versions.
I also think that PEP 387 says pretty clearly that exceptions from the policy need a Steering Council exception, but couldn't reach a friendly agreement on that :(
So, here we are: Please consider the change.