Required prerequisites
Problem description
Pybind11 originally reported a CPython bug at python/cpython#92678. It was later found that the current solution for Py_TPFLAGS_MANAGED_DICT implemented by Pybind11 does not properly support GC for their dictionaries.
Suggestion: used the newly added (3.11b5) unstable functions:
_PyObject_VisitManagedDict
_PyObject_ClearManagedDict
to properly implement tp_clear and tp_traverse for types with Py_TPFLAGS_MANAGED_DICT set.
Functions were added in https://github.com/python/cpython/pull/95256/files.
Reproducible example code
No response