Skip to content

gh-132331: Add tp_versions_used to PyTypeObject docs #132335

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

sonnyding1
Copy link
Contributor

@sonnyding1 sonnyding1 commented Apr 9, 2025

Fixes #132331. Add tp_versions_used to the tp slots section, as well as a description of the field itself. I've read through #113462 and its corresponding PR to understand how this field came about, but please let me know if there are any inaccuracies, thanks!


📚 Documentation preview 📚: https://cpython-previews--132335.org.readthedocs.build/

@python-cla-bot
Copy link

python-cla-bot bot commented Apr 18, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

@@ -2229,6 +2231,17 @@ and :c:data:`PyType_Type` effectively act as defaults.)
.. versionadded:: 3.12


.. c:member:: uint16_t PyTypeObject.tp_versions_used

Internal. Do not use.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why should we document something, just to tell people not to use it?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This field is exposed to the user who may use local PyTypeObject instances that are statically initialized (the LinuxCNC project implements that use case several places). If you do not initialize this field, then you get a warning missing initializer for member '_typeobject::tp_versions_used'.

Therefore, it should be documented (and it needs to be set to zero when statically initialized).

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

Successfully merging this pull request may close these issues.

tp_versions_used was added to PyTypeObject but is not documented
4 participants