`Py_VISIT(Py_TYPE(self))` in tp_traverse for ZstdCompressor and ZstdDecompressor

Hi all,

I’m learning heap allocated types work by studying examples in the standard library. The documentation for tp_traverse states that:

Heap types (Py_TPFLAGS_HEAPTYPE) must visit their type with:

Py_VISIT(Py_TYPE(self));

However, inside ZstdCompressor, this doesn’t seem to be the case. Likewise for ZstdDecompressor.

static int
ZstdCompressor_traverse(PyObject *ob, visitproc visit, void *arg)
{
    ZstdCompressor *self = ZstdCompressor_CAST(ob);
    Py_VISIT(self->dict);
    return 0;
}

Since the two types are heap allocated types, it seems that this goes against the documentation. Might anyone clarify the situation? Much appreciated.

Cheers

It could just be an omission. However, the types both end up marked as immutable. That at least means that the list of contents of known and fixed and so it’s probably possible to reason that the type objects can’t end up as part of a reference cycle.