Skip to content

Commit daeb0ef

Browse files
authored
gh-111178: Fix function signatures in sliceobject.c (#130575)
Rename slicehash() to slice_hash() for consistency.
1 parent 05aba4e commit daeb0ef

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

Objects/sliceobject.c

Lines changed: 17 additions & 9 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[] = {
@@ -614,8 +620,9 @@ slice_richcompare(PyObject *v, PyObject *w, int op)
614620
}
615621

616622
static int
617-
slice_traverse(PySliceObject *v, visitproc visit, void *arg)
623+
slice_traverse(PyObject *op, visitproc visit, void *arg)
618624
{
625+
PySliceObject *v = _PySlice_CAST(op);
619626
Py_VISIT(v->start);
620627
Py_VISIT(v->stop);
621628
Py_VISIT(v->step);
@@ -636,8 +643,9 @@ slice_traverse(PySliceObject *v, visitproc visit, void *arg)
636643
#endif
637644

638645
static Py_hash_t
639-
slicehash(PySliceObject *v)
646+
slice_hash(PyObject *op)
640647
{
648+
PySliceObject *v = _PySlice_CAST(op);
641649
Py_uhash_t acc = _PyHASH_XXPRIME_5;
642650
#define _PyHASH_SLICE_PART(com) { \
643651
Py_uhash_t lane = PyObject_Hash(v->com); \
@@ -663,24 +671,24 @@ PyTypeObject PySlice_Type = {
663671
"slice", /* Name of this type */
664672
sizeof(PySliceObject), /* Basic object size */
665673
0, /* Item size for varobject */
666-
(destructor)slice_dealloc, /* tp_dealloc */
674+
slice_dealloc, /* tp_dealloc */
667675
0, /* tp_vectorcall_offset */
668676
0, /* tp_getattr */
669677
0, /* tp_setattr */
670678
0, /* tp_as_async */
671-
(reprfunc)slice_repr, /* tp_repr */
679+
slice_repr, /* tp_repr */
672680
0, /* tp_as_number */
673681
0, /* tp_as_sequence */
674682
0, /* tp_as_mapping */
675-
(hashfunc)slicehash, /* tp_hash */
683+
slice_hash, /* tp_hash */
676684
0, /* tp_call */
677685
0, /* tp_str */
678686
PyObject_GenericGetAttr, /* tp_getattro */
679687
0, /* tp_setattro */
680688
0, /* tp_as_buffer */
681689
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
682690
slice_doc, /* tp_doc */
683-
(traverseproc)slice_traverse, /* tp_traverse */
691+
slice_traverse, /* tp_traverse */
684692
0, /* tp_clear */
685693
slice_richcompare, /* tp_richcompare */
686694
0, /* tp_weaklistoffset */

0 commit comments

Comments
 (0)