@@ -3237,24 +3237,29 @@ typedef struct {
32373237 PyBytesObject * it_seq ; /* Set to NULL when iterator is exhausted */
32383238} striterobject ;
32393239
3240+ #define _striterobject_CAST (op ) ((striterobject *)(op))
3241+
32403242static void
3241- striter_dealloc (striterobject * it )
3243+ striter_dealloc (PyObject * op )
32423244{
3245+ striterobject * it = _striterobject_CAST (op );
32433246 _PyObject_GC_UNTRACK (it );
32443247 Py_XDECREF (it -> it_seq );
32453248 PyObject_GC_Del (it );
32463249}
32473250
32483251static int
3249- striter_traverse (striterobject * it , visitproc visit , void * arg )
3252+ striter_traverse (PyObject * op , visitproc visit , void * arg )
32503253{
3254+ striterobject * it = _striterobject_CAST (op );
32513255 Py_VISIT (it -> it_seq );
32523256 return 0 ;
32533257}
32543258
32553259static PyObject *
3256- striter_next (striterobject * it )
3260+ striter_next (PyObject * op )
32573261{
3262+ striterobject * it = _striterobject_CAST (op );
32583263 PyBytesObject * seq ;
32593264
32603265 assert (it != NULL );
@@ -3274,8 +3279,9 @@ striter_next(striterobject *it)
32743279}
32753280
32763281static PyObject *
3277- striter_len (striterobject * it , PyObject * Py_UNUSED (ignored ))
3282+ striter_len (PyObject * op , PyObject * Py_UNUSED (ignored ))
32783283{
3284+ striterobject * it = _striterobject_CAST (op );
32793285 Py_ssize_t len = 0 ;
32803286 if (it -> it_seq )
32813287 len = PyBytes_GET_SIZE (it -> it_seq ) - it -> it_index ;
@@ -3286,14 +3292,14 @@ PyDoc_STRVAR(length_hint_doc,
32863292 "Private method returning an estimate of len(list(it))." );
32873293
32883294static PyObject *
3289- striter_reduce (striterobject * it , PyObject * Py_UNUSED (ignored ))
3295+ striter_reduce (PyObject * op , PyObject * Py_UNUSED (ignored ))
32903296{
32913297 PyObject * iter = _PyEval_GetBuiltin (& _Py_ID (iter ));
32923298
32933299 /* _PyEval_GetBuiltin can invoke arbitrary code,
32943300 * call must be before access of iterator pointers.
32953301 * see issue #101765 */
3296-
3302+ striterobject * it = _striterobject_CAST ( op );
32973303 if (it -> it_seq != NULL ) {
32983304 return Py_BuildValue ("N(O)n" , iter , it -> it_seq , it -> it_index );
32993305 } else {
@@ -3304,11 +3310,12 @@ striter_reduce(striterobject *it, PyObject *Py_UNUSED(ignored))
33043310PyDoc_STRVAR (reduce_doc , "Return state information for pickling." );
33053311
33063312static PyObject *
3307- striter_setstate (striterobject * it , PyObject * state )
3313+ striter_setstate (PyObject * op , PyObject * state )
33083314{
33093315 Py_ssize_t index = PyLong_AsSsize_t (state );
33103316 if (index == -1 && PyErr_Occurred ())
33113317 return NULL ;
3318+ striterobject * it = _striterobject_CAST (op );
33123319 if (it -> it_seq != NULL ) {
33133320 if (index < 0 )
33143321 index = 0 ;
@@ -3322,12 +3329,9 @@ striter_setstate(striterobject *it, PyObject *state)
33223329PyDoc_STRVAR (setstate_doc , "Set state information for unpickling." );
33233330
33243331static PyMethodDef striter_methods [] = {
3325- {"__length_hint__" , (PyCFunction )striter_len , METH_NOARGS ,
3326- length_hint_doc },
3327- {"__reduce__" , (PyCFunction )striter_reduce , METH_NOARGS ,
3328- reduce_doc },
3329- {"__setstate__" , (PyCFunction )striter_setstate , METH_O ,
3330- setstate_doc },
3332+ {"__length_hint__" , striter_len , METH_NOARGS , length_hint_doc },
3333+ {"__reduce__" , striter_reduce , METH_NOARGS , reduce_doc },
3334+ {"__setstate__" , striter_setstate , METH_O , setstate_doc },
33313335 {NULL , NULL } /* sentinel */
33323336};
33333337
@@ -3337,7 +3341,7 @@ PyTypeObject PyBytesIter_Type = {
33373341 sizeof (striterobject ), /* tp_basicsize */
33383342 0 , /* tp_itemsize */
33393343 /* methods */
3340- ( destructor ) striter_dealloc , /* tp_dealloc */
3344+ striter_dealloc , /* tp_dealloc */
33413345 0 , /* tp_vectorcall_offset */
33423346 0 , /* tp_getattr */
33433347 0 , /* tp_setattr */
@@ -3354,12 +3358,12 @@ PyTypeObject PyBytesIter_Type = {
33543358 0 , /* tp_as_buffer */
33553359 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC ,/* tp_flags */
33563360 0 , /* tp_doc */
3357- ( traverseproc ) striter_traverse , /* tp_traverse */
3361+ striter_traverse , /* tp_traverse */
33583362 0 , /* tp_clear */
33593363 0 , /* tp_richcompare */
33603364 0 , /* tp_weaklistoffset */
33613365 PyObject_SelfIter , /* tp_iter */
3362- ( iternextfunc ) striter_next , /* tp_iternext */
3366+ striter_next , /* tp_iternext */
33633367 striter_methods , /* tp_methods */
33643368 0 ,
33653369};
0 commit comments