Skip to content

Commit

Permalink
pythongh-111178: Fix function signatures in structseq.c (python#130683)
Browse files Browse the repository at this point in the history
  • Loading branch information
vstinner authored Mar 4, 2025
1 parent ed8675c commit 0b6e98c
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions Objects/structseq.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand All @@ -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);

Expand Down Expand Up @@ -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, "
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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 */
Expand Down

0 comments on commit 0b6e98c

Please sign in to comment.