This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients pablogsal, vstinner
Date 2020-06-19.14:05:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
While reviewing changes of bpo-40077 "Convert static types to PyType_FromSpec()", I noticed that some static types don't implement tp_traverse.

The doc says:

    Heap-allocated types (...) hold a reference to their type. Their traversal function must therefore either visit Py_TYPE(self), or delegate this responsibility by calling tp_traverse of another heap-allocated type (such as a heap-allocated superclass). If they do not, the type object may not be garbage-collected.

Porting to 3.9 says:

    for types that have a custom tp_traverse function, ensure that all custom tp_traverse functions of heap-allocated types visit the object’s type


It seems like converting a static type to a heap allocated type requires to *add* a new tp_traverse function, if it wasn't the case.

Maybe we can provide a base tp_traverse implementation in the base object type: visit the type if it's a heap type?

See attached PR.

See bpo-35810 and bpo-40217 for more information.
Date User Action Args
2020-06-19 14:05:01vstinnersetrecipients: + vstinner, pablogsal
2020-06-19 14:05:01vstinnersetmessageid: <>
2020-06-19 14:05:01vstinnerlinkissue41036 messages
2020-06-19 14:05:00vstinnercreate