Skip to content

Commit

Permalink
pythongh-111178: Fix function signatures in sliceobject.c
Browse files Browse the repository at this point in the history
Rename slicehash() to slice_hash() for consistency.
  • Loading branch information
vstinner committed Feb 26, 2025
1 parent f976892 commit a5584f6
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 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 @@ -636,8 +642,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,16 +670,16 @@ 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 */
Expand Down

0 comments on commit a5584f6

Please sign in to comment.