From ffb2a01f0a952223b251aec628e47379c6985cd2 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 28 Feb 2025 12:51:24 +0100 Subject: [PATCH] gh-111178: Fix function signatures in structseq.c --- Objects/structseq.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/Objects/structseq.c b/Objects/structseq.c index 56a7851b98788d..b62317e1cf3732 100644 --- a/Objects/structseq.c +++ b/Objects/structseq.c @@ -108,8 +108,9 @@ PyStructSequence_GetItem(PyObject *op, Py_ssize_t index) static int -structseq_traverse(PyStructSequence *obj, visitproc visit, void *arg) +structseq_traverse(PyObject *op, visitproc visit, void *arg) { + PyStructSequence *obj = (PyStructSequence *)op; if (Py_TYPE(obj)->tp_flags & Py_TPFLAGS_HEAPTYPE) { Py_VISIT(Py_TYPE(obj)); } @@ -122,8 +123,9 @@ structseq_traverse(PyStructSequence *obj, visitproc visit, void *arg) } static void -structseq_dealloc(PyStructSequence *obj) +structseq_dealloc(PyObject *op) { + PyStructSequence *obj = (PyStructSequence *)op; Py_ssize_t i, size; PyObject_GC_UnTrack(obj); @@ -263,8 +265,9 @@ structseq_new_impl(PyTypeObject *type, PyObject *arg, PyObject *dict) static PyObject * -structseq_repr(PyStructSequence *obj) +structseq_repr(PyObject *op) { + PyStructSequence *obj = (PyStructSequence *)op; PyTypeObject *typ = Py_TYPE(obj); // count 5 characters per item: "x=1, " @@ -568,14 +571,14 @@ initialize_static_fields(PyTypeObject *type, PyStructSequence_Desc *desc, Py_ssize_t n_hidden = n_members - desc->n_in_sequence; type->tp_basicsize = sizeof(PyStructSequence) + (n_hidden - 1) * sizeof(PyObject *); type->tp_itemsize = sizeof(PyObject *); - type->tp_dealloc = (destructor)structseq_dealloc; - type->tp_repr = (reprfunc)structseq_repr; + type->tp_dealloc = structseq_dealloc; + type->tp_repr = structseq_repr; type->tp_doc = desc->doc; type->tp_base = &PyTuple_Type; type->tp_methods = structseq_methods; type->tp_new = structseq_new; type->tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | tp_flags; - type->tp_traverse = (traverseproc) structseq_traverse; + type->tp_traverse = structseq_traverse; type->tp_members = tp_members; } @@ -745,13 +748,13 @@ _PyStructSequence_NewType(PyStructSequence_Desc *desc, unsigned long tp_flags) } /* Initialize Slots */ - slots[0] = (PyType_Slot){Py_tp_dealloc, (destructor)structseq_dealloc}; - slots[1] = (PyType_Slot){Py_tp_repr, (reprfunc)structseq_repr}; + slots[0] = (PyType_Slot){Py_tp_dealloc, structseq_dealloc}; + slots[1] = (PyType_Slot){Py_tp_repr, structseq_repr}; slots[2] = (PyType_Slot){Py_tp_doc, (void *)desc->doc}; slots[3] = (PyType_Slot){Py_tp_methods, structseq_methods}; slots[4] = (PyType_Slot){Py_tp_new, structseq_new}; slots[5] = (PyType_Slot){Py_tp_members, members}; - slots[6] = (PyType_Slot){Py_tp_traverse, (traverseproc)structseq_traverse}; + slots[6] = (PyType_Slot){Py_tp_traverse, structseq_traverse}; slots[7] = (PyType_Slot){0, 0}; /* Initialize Spec */