Skip to content

[BUG]: [CPython 3.11] GC not implemented properly for objects with managed dictionaries #4092

Closed
@Fidget-Spinner

Description

@Fidget-Spinner

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions