Skip to content

Commit a5584f6

Browse files
committed
gh-111178: Fix function signatures in sliceobject.c
Rename slicehash() to slice_hash() for consistency.
1 parent f976892 commit a5584f6

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

Objects/sliceobject.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ this type and there is exactly one in existence.
2121
#include "pycore_object.h" // _PyObject_GC_TRACK()
2222

2323

24+
#define _PySlice_CAST(op) _Py_CAST(PySliceObject*, (op))
25+
26+
2427
static PyObject *
2528
ellipsis_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
2629
{
@@ -341,8 +344,9 @@ slice(start, stop[, step])\n\
341344
Create a slice object. This is used for extended slicing (e.g. a[0:10:2]).");
342345

343346
static void
344-
slice_dealloc(PySliceObject *r)
347+
slice_dealloc(PyObject *op)
345348
{
349+
PySliceObject *r = _PySlice_CAST(op);
346350
PyObject_GC_UnTrack(r);
347351
Py_DECREF(r->step);
348352
Py_DECREF(r->start);
@@ -351,9 +355,11 @@ slice_dealloc(PySliceObject *r)
351355
}
352356

353357
static PyObject *
354-
slice_repr(PySliceObject *r)
358+
slice_repr(PyObject *op)
355359
{
356-
return PyUnicode_FromFormat("slice(%R, %R, %R)", r->start, r->stop, r->step);
360+
PySliceObject *r = _PySlice_CAST(op);
361+
return PyUnicode_FromFormat("slice(%R, %R, %R)",
362+
r->start, r->stop, r->step);
357363
}
358364

359365
static PyMemberDef slice_members[] = {
@@ -636,8 +642,9 @@ slice_traverse(PySliceObject *v, visitproc visit, void *arg)
636642
#endif
637643

638644
static Py_hash_t
639-
slicehash(PySliceObject *v)
645+
slice_hash(PyObject *op)
640646
{
647+
PySliceObject *v = _PySlice_CAST(op);
641648
Py_uhash_t acc = _PyHASH_XXPRIME_5;
642649
#define _PyHASH_SLICE_PART(com) { \
643650
Py_uhash_t lane = PyObject_Hash(v->com); \
@@ -663,16 +670,16 @@ PyTypeObject PySlice_Type = {
663670
"slice", /* Name of this type */
664671
sizeof(PySliceObject), /* Basic object size */
665672
0, /* Item size for varobject */
666-
(destructor)slice_dealloc, /* tp_dealloc */
673+
slice_dealloc, /* tp_dealloc */
667674
0, /* tp_vectorcall_offset */
668675
0, /* tp_getattr */
669676
0, /* tp_setattr */
670677
0, /* tp_as_async */
671-
(reprfunc)slice_repr, /* tp_repr */
678+
slice_repr, /* tp_repr */
672679
0, /* tp_as_number */
673680
0, /* tp_as_sequence */
674681
0, /* tp_as_mapping */
675-
(hashfunc)slicehash, /* tp_hash */
682+
slice_hash, /* tp_hash */
676683
0, /* tp_call */
677684
0, /* tp_str */
678685
PyObject_GenericGetAttr, /* tp_getattro */

0 commit comments

Comments
 (0)