Skip to content

gh-145921: Add "_DuringGC" functions for tp_traverse#145925

Open
encukou wants to merge 2 commits intopython:mainfrom
encukou:during-gc
Open

gh-145921: Add "_DuringGC" functions for tp_traverse#145925
encukou wants to merge 2 commits intopython:mainfrom
encukou:during-gc

Conversation

@encukou
Copy link
Member

@encukou encukou commented Mar 13, 2026

There are newly documented restrictions on tp_traverse:

The traversal function must not have any side effects.
It must not modify the reference counts of any Python
objects nor create or destroy any Python objects.

  • Add several functions that are guaranteed side-effect-free, with a _DuringGC suffix.
  • Use these in ctypes
  • Consolidate tp_traverse docs in gcsupport.rst, moving unique content from typeobj.rst there

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

There are newly documented restrictions on tp_traverse:

    The traversal function must not have any side effects.
    It must not modify the reference counts of any Python
    objects nor create or destroy any Python objects.

* Add several functions that are guaranteed side-effect-free,
  with a _DuringGC suffix.
* Use these in ctypes
* Consolidate tp_traverse docs in gcsupport.rst, moving unique
  content from typeobj.rst there
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants