gh-124153: Add Py_tp_token support to xxlimited module #141644
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Implement the TODO at line 99-100 in
Modules/xxlimited.cto addPy_tp_tokenslot support, demonstrating Python 3.14 type checking best practices for Limited C API extension modules.Changes
Py_tp_tokenslot withPy_TP_USE_SPECtoXxo_Type_slotsRationale
This addresses the type-checking problem for heap types described in PEP 630. The xxlimited module serves as a template for extension developers, and this change demonstrates modern Python 3.14 type-checking best practices using the
Py_tp_tokenfeature added in #124153.Relates to #134160 (documentation modernization).
PR description written with Claude Code.
PyType_GetBaseByTokenfunction withPy_tp_tokenslot #124153📚 Documentation preview 📚: https://cpython-previews--141644.org.readthedocs.build/