@@ -3085,7 +3085,7 @@ PyTypeObject PyBytes_Type = {
30853085 bytes_doc , /* tp_doc */
30863086 0 , /* tp_traverse */
30873087 0 , /* tp_clear */
3088- ( richcmpfunc ) bytes_richcompare , /* tp_richcompare */
3088+ bytes_richcompare , /* tp_richcompare */
30893089 0 , /* tp_weaklistoffset */
30903090 bytes_iter , /* tp_iter */
30913091 0 , /* tp_iternext */
@@ -3245,24 +3245,29 @@ typedef struct {
32453245 PyBytesObject * it_seq ; /* Set to NULL when iterator is exhausted */
32463246} striterobject ;
32473247
3248+ #define _striterobject_CAST (op ) ((striterobject *)(op))
3249+
32483250static void
3249- striter_dealloc (striterobject * it )
3251+ striter_dealloc (PyObject * op )
32503252{
3253+ striterobject * it = _striterobject_CAST (op );
32513254 _PyObject_GC_UNTRACK (it );
32523255 Py_XDECREF (it -> it_seq );
32533256 PyObject_GC_Del (it );
32543257}
32553258
32563259static int
3257- striter_traverse (striterobject * it , visitproc visit , void * arg )
3260+ striter_traverse (PyObject * op , visitproc visit , void * arg )
32583261{
3262+ striterobject * it = _striterobject_CAST (op );
32593263 Py_VISIT (it -> it_seq );
32603264 return 0 ;
32613265}
32623266
32633267static PyObject *
3264- striter_next (striterobject * it )
3268+ striter_next (PyObject * op )
32653269{
3270+ striterobject * it = _striterobject_CAST (op );
32663271 PyBytesObject * seq ;
32673272
32683273 assert (it != NULL );
@@ -3282,8 +3287,9 @@ striter_next(striterobject *it)
32823287}
32833288
32843289static PyObject *
3285- striter_len (striterobject * it , PyObject * Py_UNUSED (ignored ))
3290+ striter_len (PyObject * op , PyObject * Py_UNUSED (ignored ))
32863291{
3292+ striterobject * it = _striterobject_CAST (op );
32873293 Py_ssize_t len = 0 ;
32883294 if (it -> it_seq )
32893295 len = PyBytes_GET_SIZE (it -> it_seq ) - it -> it_index ;
@@ -3294,14 +3300,14 @@ PyDoc_STRVAR(length_hint_doc,
32943300 "Private method returning an estimate of len(list(it))." );
32953301
32963302static PyObject *
3297- striter_reduce (striterobject * it , PyObject * Py_UNUSED (ignored ))
3303+ striter_reduce (PyObject * op , PyObject * Py_UNUSED (ignored ))
32983304{
32993305 PyObject * iter = _PyEval_GetBuiltin (& _Py_ID (iter ));
33003306
33013307 /* _PyEval_GetBuiltin can invoke arbitrary code,
33023308 * call must be before access of iterator pointers.
33033309 * see issue #101765 */
3304-
3310+ striterobject * it = _striterobject_CAST ( op );
33053311 if (it -> it_seq != NULL ) {
33063312 return Py_BuildValue ("N(O)n" , iter , it -> it_seq , it -> it_index );
33073313 } else {
@@ -3312,11 +3318,12 @@ striter_reduce(striterobject *it, PyObject *Py_UNUSED(ignored))
33123318PyDoc_STRVAR (reduce_doc , "Return state information for pickling." );
33133319
33143320static PyObject *
3315- striter_setstate (striterobject * it , PyObject * state )
3321+ striter_setstate (PyObject * op , PyObject * state )
33163322{
33173323 Py_ssize_t index = PyLong_AsSsize_t (state );
33183324 if (index == -1 && PyErr_Occurred ())
33193325 return NULL ;
3326+ striterobject * it = _striterobject_CAST (op );
33203327 if (it -> it_seq != NULL ) {
33213328 if (index < 0 )
33223329 index = 0 ;
@@ -3330,12 +3337,9 @@ striter_setstate(striterobject *it, PyObject *state)
33303337PyDoc_STRVAR (setstate_doc , "Set state information for unpickling." );
33313338
33323339static PyMethodDef striter_methods [] = {
3333- {"__length_hint__" , (PyCFunction )striter_len , METH_NOARGS ,
3334- length_hint_doc },
3335- {"__reduce__" , (PyCFunction )striter_reduce , METH_NOARGS ,
3336- reduce_doc },
3337- {"__setstate__" , (PyCFunction )striter_setstate , METH_O ,
3338- setstate_doc },
3340+ {"__length_hint__" , striter_len , METH_NOARGS , length_hint_doc },
3341+ {"__reduce__" , striter_reduce , METH_NOARGS , reduce_doc },
3342+ {"__setstate__" , striter_setstate , METH_O , setstate_doc },
33393343 {NULL , NULL } /* sentinel */
33403344};
33413345
@@ -3345,7 +3349,7 @@ PyTypeObject PyBytesIter_Type = {
33453349 sizeof (striterobject ), /* tp_basicsize */
33463350 0 , /* tp_itemsize */
33473351 /* methods */
3348- ( destructor ) striter_dealloc , /* tp_dealloc */
3352+ striter_dealloc , /* tp_dealloc */
33493353 0 , /* tp_vectorcall_offset */
33503354 0 , /* tp_getattr */
33513355 0 , /* tp_setattr */
@@ -3362,12 +3366,12 @@ PyTypeObject PyBytesIter_Type = {
33623366 0 , /* tp_as_buffer */
33633367 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC ,/* tp_flags */
33643368 0 , /* tp_doc */
3365- ( traverseproc ) striter_traverse , /* tp_traverse */
3369+ striter_traverse , /* tp_traverse */
33663370 0 , /* tp_clear */
33673371 0 , /* tp_richcompare */
33683372 0 , /* tp_weaklistoffset */
33693373 PyObject_SelfIter , /* tp_iter */
3370- ( iternextfunc ) striter_next , /* tp_iternext */
3374+ striter_next , /* tp_iternext */
33713375 striter_methods , /* tp_methods */
33723376 0 ,
33733377};
0 commit comments