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.
Documentation
The
tp_deallocComplete Example has no trashcan, and callsPyObject_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_ENDare 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.