Skip to content

gh-111178: Fix function signatures in sliceobject.c #130575

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 26, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions Objects/sliceobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ this type and there is exactly one in existence.
#include "pycore_object.h" // _PyObject_GC_TRACK()


#define _PySlice_CAST(op) _Py_CAST(PySliceObject*, (op))


static PyObject *
ellipsis_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
{
Expand Down Expand Up @@ -341,8 +344,9 @@ slice(start, stop[, step])\n\
Create a slice object. This is used for extended slicing (e.g. a[0:10:2]).");

static void
slice_dealloc(PySliceObject *r)
slice_dealloc(PyObject *op)
{
PySliceObject *r = _PySlice_CAST(op);
PyObject_GC_UnTrack(r);
Py_DECREF(r->step);
Py_DECREF(r->start);
Expand All @@ -351,9 +355,11 @@ slice_dealloc(PySliceObject *r)
}

static PyObject *
slice_repr(PySliceObject *r)
slice_repr(PyObject *op)
{
return PyUnicode_FromFormat("slice(%R, %R, %R)", r->start, r->stop, r->step);
PySliceObject *r = _PySlice_CAST(op);
return PyUnicode_FromFormat("slice(%R, %R, %R)",
r->start, r->stop, r->step);
}

static PyMemberDef slice_members[] = {
Expand Down Expand Up @@ -614,8 +620,9 @@ slice_richcompare(PyObject *v, PyObject *w, int op)
}

static int
slice_traverse(PySliceObject *v, visitproc visit, void *arg)
slice_traverse(PyObject *op, visitproc visit, void *arg)
{
PySliceObject *v = _PySlice_CAST(op);
Py_VISIT(v->start);
Py_VISIT(v->stop);
Py_VISIT(v->step);
Expand All @@ -636,8 +643,9 @@ slice_traverse(PySliceObject *v, visitproc visit, void *arg)
#endif

static Py_hash_t
slicehash(PySliceObject *v)
slice_hash(PyObject *op)
{
PySliceObject *v = _PySlice_CAST(op);
Py_uhash_t acc = _PyHASH_XXPRIME_5;
#define _PyHASH_SLICE_PART(com) { \
Py_uhash_t lane = PyObject_Hash(v->com); \
Expand All @@ -663,24 +671,24 @@ PyTypeObject PySlice_Type = {
"slice", /* Name of this type */
sizeof(PySliceObject), /* Basic object size */
0, /* Item size for varobject */
(destructor)slice_dealloc, /* tp_dealloc */
slice_dealloc, /* tp_dealloc */
0, /* tp_vectorcall_offset */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_as_async */
(reprfunc)slice_repr, /* tp_repr */
slice_repr, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
(hashfunc)slicehash, /* tp_hash */
slice_hash, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
slice_doc, /* tp_doc */
(traverseproc)slice_traverse, /* tp_traverse */
slice_traverse, /* tp_traverse */
0, /* tp_clear */
slice_richcompare, /* tp_richcompare */
0, /* tp_weaklistoffset */
Expand Down
Loading