mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
GH-92678: Expose managed dict clear and visit functions (#95246)
This commit is contained in:
parent
2d26449b06
commit
27055d766a
5 changed files with 57 additions and 0 deletions
|
@ -5583,6 +5583,35 @@ _PyObject_FreeInstanceAttributes(PyObject *self)
|
|||
free_values(*values_ptr);
|
||||
}
|
||||
|
||||
int
|
||||
_PyObject_VisitManagedDict(PyObject *self, visitproc visit, void *arg)
|
||||
{
|
||||
PyTypeObject *tp = Py_TYPE(self);
|
||||
if((tp->tp_flags & Py_TPFLAGS_MANAGED_DICT) == 0) {
|
||||
return 0;
|
||||
}
|
||||
assert(tp->tp_dictoffset);
|
||||
int err = _PyObject_VisitInstanceAttributes(self, visit, arg);
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
Py_VISIT(*_PyObject_ManagedDictPointer(self));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
_PyObject_ClearManagedDict(PyObject *self)
|
||||
{
|
||||
PyTypeObject *tp = Py_TYPE(self);
|
||||
if((tp->tp_flags & Py_TPFLAGS_MANAGED_DICT) == 0) {
|
||||
return;
|
||||
}
|
||||
_PyObject_FreeInstanceAttributes(self);
|
||||
*_PyObject_ValuesPointer(self) = NULL;
|
||||
Py_CLEAR(*_PyObject_ManagedDictPointer(self));
|
||||
}
|
||||
|
||||
PyObject *
|
||||
PyObject_GenericGetDict(PyObject *obj, void *context)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue