@@ -3085,7 +3085,7 @@ PyTypeObject PyBytes_Type = {
3085
3085
bytes_doc , /* tp_doc */
3086
3086
0 , /* tp_traverse */
3087
3087
0 , /* tp_clear */
3088
- ( richcmpfunc ) bytes_richcompare , /* tp_richcompare */
3088
+ bytes_richcompare , /* tp_richcompare */
3089
3089
0 , /* tp_weaklistoffset */
3090
3090
bytes_iter , /* tp_iter */
3091
3091
0 , /* tp_iternext */
@@ -3245,24 +3245,29 @@ typedef struct {
3245
3245
PyBytesObject * it_seq ; /* Set to NULL when iterator is exhausted */
3246
3246
} striterobject ;
3247
3247
3248
+ #define _striterobject_CAST (op ) ((striterobject *)(op))
3249
+
3248
3250
static void
3249
- striter_dealloc (striterobject * it )
3251
+ striter_dealloc (PyObject * op )
3250
3252
{
3253
+ striterobject * it = _striterobject_CAST (op );
3251
3254
_PyObject_GC_UNTRACK (it );
3252
3255
Py_XDECREF (it -> it_seq );
3253
3256
PyObject_GC_Del (it );
3254
3257
}
3255
3258
3256
3259
static int
3257
- striter_traverse (striterobject * it , visitproc visit , void * arg )
3260
+ striter_traverse (PyObject * op , visitproc visit , void * arg )
3258
3261
{
3262
+ striterobject * it = _striterobject_CAST (op );
3259
3263
Py_VISIT (it -> it_seq );
3260
3264
return 0 ;
3261
3265
}
3262
3266
3263
3267
static PyObject *
3264
- striter_next (striterobject * it )
3268
+ striter_next (PyObject * op )
3265
3269
{
3270
+ striterobject * it = _striterobject_CAST (op );
3266
3271
PyBytesObject * seq ;
3267
3272
3268
3273
assert (it != NULL );
@@ -3282,8 +3287,9 @@ striter_next(striterobject *it)
3282
3287
}
3283
3288
3284
3289
static PyObject *
3285
- striter_len (striterobject * it , PyObject * Py_UNUSED (ignored ))
3290
+ striter_len (PyObject * op , PyObject * Py_UNUSED (ignored ))
3286
3291
{
3292
+ striterobject * it = _striterobject_CAST (op );
3287
3293
Py_ssize_t len = 0 ;
3288
3294
if (it -> it_seq )
3289
3295
len = PyBytes_GET_SIZE (it -> it_seq ) - it -> it_index ;
@@ -3294,14 +3300,14 @@ PyDoc_STRVAR(length_hint_doc,
3294
3300
"Private method returning an estimate of len(list(it))." );
3295
3301
3296
3302
static PyObject *
3297
- striter_reduce (striterobject * it , PyObject * Py_UNUSED (ignored ))
3303
+ striter_reduce (PyObject * op , PyObject * Py_UNUSED (ignored ))
3298
3304
{
3299
3305
PyObject * iter = _PyEval_GetBuiltin (& _Py_ID (iter ));
3300
3306
3301
3307
/* _PyEval_GetBuiltin can invoke arbitrary code,
3302
3308
* call must be before access of iterator pointers.
3303
3309
* see issue #101765 */
3304
-
3310
+ striterobject * it = _striterobject_CAST ( op );
3305
3311
if (it -> it_seq != NULL ) {
3306
3312
return Py_BuildValue ("N(O)n" , iter , it -> it_seq , it -> it_index );
3307
3313
} else {
@@ -3312,11 +3318,12 @@ striter_reduce(striterobject *it, PyObject *Py_UNUSED(ignored))
3312
3318
PyDoc_STRVAR (reduce_doc , "Return state information for pickling." );
3313
3319
3314
3320
static PyObject *
3315
- striter_setstate (striterobject * it , PyObject * state )
3321
+ striter_setstate (PyObject * op , PyObject * state )
3316
3322
{
3317
3323
Py_ssize_t index = PyLong_AsSsize_t (state );
3318
3324
if (index == -1 && PyErr_Occurred ())
3319
3325
return NULL ;
3326
+ striterobject * it = _striterobject_CAST (op );
3320
3327
if (it -> it_seq != NULL ) {
3321
3328
if (index < 0 )
3322
3329
index = 0 ;
@@ -3330,12 +3337,9 @@ striter_setstate(striterobject *it, PyObject *state)
3330
3337
PyDoc_STRVAR (setstate_doc , "Set state information for unpickling." );
3331
3338
3332
3339
static 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 },
3339
3343
{NULL , NULL } /* sentinel */
3340
3344
};
3341
3345
@@ -3345,7 +3349,7 @@ PyTypeObject PyBytesIter_Type = {
3345
3349
sizeof (striterobject ), /* tp_basicsize */
3346
3350
0 , /* tp_itemsize */
3347
3351
/* methods */
3348
- ( destructor ) striter_dealloc , /* tp_dealloc */
3352
+ striter_dealloc , /* tp_dealloc */
3349
3353
0 , /* tp_vectorcall_offset */
3350
3354
0 , /* tp_getattr */
3351
3355
0 , /* tp_setattr */
@@ -3362,12 +3366,12 @@ PyTypeObject PyBytesIter_Type = {
3362
3366
0 , /* tp_as_buffer */
3363
3367
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC ,/* tp_flags */
3364
3368
0 , /* tp_doc */
3365
- ( traverseproc ) striter_traverse , /* tp_traverse */
3369
+ striter_traverse , /* tp_traverse */
3366
3370
0 , /* tp_clear */
3367
3371
0 , /* tp_richcompare */
3368
3372
0 , /* tp_weaklistoffset */
3369
3373
PyObject_SelfIter , /* tp_iter */
3370
- ( iternextfunc ) striter_next , /* tp_iternext */
3374
+ striter_next , /* tp_iternext */
3371
3375
striter_methods , /* tp_methods */
3372
3376
0 ,
3373
3377
};
0 commit comments