mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-138342: Use a common utility for visiting an object's type (GH-138343)
Add `_PyObject_VisitType` in place of `tp_traverse` functions that only visit the object's type.
This commit is contained in:
parent
0d02e4d7d3
commit
4f6ecd10c2
24 changed files with 41 additions and 203 deletions
|
|
@ -655,13 +655,6 @@ PyThreadHandleObject_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
|||
return (PyObject *)PyThreadHandleObject_new(type);
|
||||
}
|
||||
|
||||
static int
|
||||
PyThreadHandleObject_traverse(PyObject *self, visitproc visit, void *arg)
|
||||
{
|
||||
Py_VISIT(Py_TYPE(self));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
PyThreadHandleObject_dealloc(PyObject *op)
|
||||
{
|
||||
|
|
@ -751,7 +744,7 @@ static PyType_Slot ThreadHandle_Type_slots[] = {
|
|||
{Py_tp_dealloc, PyThreadHandleObject_dealloc},
|
||||
{Py_tp_repr, PyThreadHandleObject_repr},
|
||||
{Py_tp_getset, ThreadHandle_getsetlist},
|
||||
{Py_tp_traverse, PyThreadHandleObject_traverse},
|
||||
{Py_tp_traverse, _PyObject_VisitType},
|
||||
{Py_tp_methods, ThreadHandle_methods},
|
||||
{Py_tp_new, PyThreadHandleObject_tp_new},
|
||||
{0, 0}
|
||||
|
|
@ -767,13 +760,6 @@ static PyType_Spec ThreadHandle_Type_spec = {
|
|||
|
||||
/* Lock objects */
|
||||
|
||||
static int
|
||||
lock_traverse(PyObject *self, visitproc visit, void *arg)
|
||||
{
|
||||
Py_VISIT(Py_TYPE(self));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
lock_dealloc(PyObject *self)
|
||||
{
|
||||
|
|
@ -1045,7 +1031,7 @@ static PyType_Slot lock_type_slots[] = {
|
|||
{Py_tp_repr, lock_repr},
|
||||
{Py_tp_doc, (void *)lock_doc},
|
||||
{Py_tp_methods, lock_methods},
|
||||
{Py_tp_traverse, lock_traverse},
|
||||
{Py_tp_traverse, _PyObject_VisitType},
|
||||
{Py_tp_new, lock_new},
|
||||
{0, 0}
|
||||
};
|
||||
|
|
@ -1060,13 +1046,6 @@ static PyType_Spec lock_type_spec = {
|
|||
|
||||
/* Recursive lock objects */
|
||||
|
||||
static int
|
||||
rlock_traverse(PyObject *self, visitproc visit, void *arg)
|
||||
{
|
||||
Py_VISIT(Py_TYPE(self));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
rlock_locked_impl(rlockobject *self)
|
||||
{
|
||||
|
|
@ -1359,7 +1338,7 @@ static PyType_Slot rlock_type_slots[] = {
|
|||
{Py_tp_methods, rlock_methods},
|
||||
{Py_tp_alloc, PyType_GenericAlloc},
|
||||
{Py_tp_new, rlock_new},
|
||||
{Py_tp_traverse, rlock_traverse},
|
||||
{Py_tp_traverse, _PyObject_VisitType},
|
||||
{0, 0},
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue