gh-134786: raise error if Py_TPFLAGS_MANAGED_WEAKREF or Py_TPFLAGS_MANAGED_DICT is used without Py_TPFLAGS_HAVE_GC set (#135863)

This commit is contained in:
Sergey Miryanov 2025-11-02 16:04:49 +05:00 committed by GitHub
parent d12cbf2865
commit da65f38a94
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 72 additions and 2 deletions

View file

@ -1260,7 +1260,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
This bit indicates that instances of the class have a :attr:`~object.__dict__`
attribute, and that the space for the dictionary is managed by the VM.
If this flag is set, :c:macro:`Py_TPFLAGS_HAVE_GC` should also be set.
If this flag is set, :c:macro:`Py_TPFLAGS_HAVE_GC` must also be set.
The type traverse function must call :c:func:`PyObject_VisitManagedDict`
and its clear function must call :c:func:`PyObject_ClearManagedDict`.
@ -1278,6 +1278,8 @@ and :c:data:`PyType_Type` effectively act as defaults.)
This bit indicates that instances of the class should be weakly
referenceable.
If this flag is set, :c:macro:`Py_TPFLAGS_HAVE_GC` must also be set.
.. versionadded:: 3.12
**Inheritance:**