Skip to content

tp_dealloc example may need the trashcan for GC container types #158619

Description

@aeroyorch

Documentation

The tp_dealloc Complete Example has no trashcan, and calls PyObject_CallFinalizerFromDealloc() before anything else. A GC type whose instances can reference other instances of the same type recurses without bound if it follows that shape.

Since the macros Py_TRASHCAN_BEGIN / Py_TRASHCAN_END are not in the C API reference at all, that example is the natural thing to copy for a new GC type. Would a note there make sense, or is the trashcan deliberately out of scope for the ref docs? It is also not clear to me whether gh-124715 and gh-132280 already solve this from 3.14 on.

Activity

  1. sergey-miryanov commented on Oct 2, 2026

    @sergey-miryanov
    Contributor

    Trashcan is an implementation detail, so I don't think we need to document it. Py_TRASHCAN_BEGIN and Py_TRASHCAN_END were kept for backward compatibility.

  2. added
    pendingThe issue will be closed if no feedback is provided
    on Oct 3, 2026
  3. yummyPancake2607 commented on Oct 4, 2026

    @yummyPancake2607

    i would like to work on this issue if no one is working on it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dirpendingThe issue will be closed if no feedback is provided

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions