gh-124153: Add Py_tp_token support to xxlimited module
Summary
Implement the TODO at line 99-100 in Modules/xxlimited.c to add Py_tp_token slot support, demonstrating Python 3.14 type checking best practices for Limited C API extension modules.
Changes
- Update Limited API version from 3.13 to 3.14
- Add
Py_tp_tokenslot withPy_TP_USE_SPECtoXxo_Type_slots - Add "Type Checking with Heap Types" section to isolating-extensions.rst
Rationale
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_token feature added in #124153.
Relates to #134160 (documentation modernization).
PR description written with Claude Code.
- Issue: gh-124153
📚 Documentation preview 📚: https://cpython-previews--141644.org.readthedocs.build/
I guess my question about this is... should we recommend people always do this? is there a downside worth mentioning? cc @neonene as well as the original author of the 3.14 feature PR.
https://github.com/python/cpython/pull/142827 adds a Xxo_state_from_type function and several examples of getting state->Xxo_Type from that. It also removes the TODO.
After/if that's merged, I plan to adapt the HOWTO addition from this PR after that. And ideally add an actual example of type-checking :)