mirror of
https://github.com/python/cpython.git
synced 2025-12-02 23:57:43 +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
|
|
@ -29,13 +29,6 @@ pysqlite_prepare_protocol_init(PyObject *self, PyObject *args, PyObject *kwargs)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
pysqlite_prepare_protocol_traverse(PyObject *self, visitproc visit, void *arg)
|
||||
{
|
||||
Py_VISIT(Py_TYPE(self));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
pysqlite_prepare_protocol_dealloc(PyObject *self)
|
||||
{
|
||||
|
|
@ -50,7 +43,7 @@ PyDoc_STRVAR(doc, "PEP 246 style object adaption protocol type.");
|
|||
static PyType_Slot type_slots[] = {
|
||||
{Py_tp_dealloc, pysqlite_prepare_protocol_dealloc},
|
||||
{Py_tp_init, pysqlite_prepare_protocol_init},
|
||||
{Py_tp_traverse, pysqlite_prepare_protocol_traverse},
|
||||
{Py_tp_traverse, _PyObject_VisitType},
|
||||
{Py_tp_doc, (void *)doc},
|
||||
{0, NULL},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -116,13 +116,6 @@ stmt_dealloc(PyObject *op)
|
|||
Py_DECREF(tp);
|
||||
}
|
||||
|
||||
static int
|
||||
stmt_traverse(PyObject *self, visitproc visit, void *arg)
|
||||
{
|
||||
Py_VISIT(Py_TYPE(self));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Strip leading whitespace and comments from incoming SQL (null terminated C
|
||||
* string) and return a pointer to the first non-whitespace, non-comment
|
||||
|
|
@ -183,7 +176,7 @@ lstrip_sql(const char *sql)
|
|||
|
||||
static PyType_Slot stmt_slots[] = {
|
||||
{Py_tp_dealloc, stmt_dealloc},
|
||||
{Py_tp_traverse, stmt_traverse},
|
||||
{Py_tp_traverse, _PyObject_VisitType},
|
||||
{0, NULL},
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue