@@ -494,6 +494,8 @@ typedef struct {
494
494
PyObject * it ;
495
495
} filterobject ;
496
496
497
+ #define _filterobject_CAST (op ) ((filterobject *)(op))
498
+
497
499
static PyObject *
498
500
filter_new (PyTypeObject * type , PyObject * args , PyObject * kwds )
499
501
{
@@ -559,8 +561,9 @@ filter_vectorcall(PyObject *type, PyObject * const*args,
559
561
}
560
562
561
563
static void
562
- filter_dealloc (filterobject * lz )
564
+ filter_dealloc (PyObject * self )
563
565
{
566
+ filterobject * lz = _filterobject_CAST (self );
564
567
PyObject_GC_UnTrack (lz );
565
568
Py_TRASHCAN_BEGIN (lz , filter_dealloc )
566
569
Py_XDECREF (lz -> func );
@@ -570,16 +573,18 @@ filter_dealloc(filterobject *lz)
570
573
}
571
574
572
575
static int
573
- filter_traverse (filterobject * lz , visitproc visit , void * arg )
576
+ filter_traverse (PyObject * self , visitproc visit , void * arg )
574
577
{
578
+ filterobject * lz = _filterobject_CAST (self );
575
579
Py_VISIT (lz -> it );
576
580
Py_VISIT (lz -> func );
577
581
return 0 ;
578
582
}
579
583
580
584
static PyObject *
581
- filter_next (filterobject * lz )
585
+ filter_next (PyObject * self )
582
586
{
587
+ filterobject * lz = _filterobject_CAST (self );
583
588
PyObject * item ;
584
589
PyObject * it = lz -> it ;
585
590
long ok ;
@@ -613,15 +618,16 @@ filter_next(filterobject *lz)
613
618
}
614
619
615
620
static PyObject *
616
- filter_reduce (filterobject * lz , PyObject * Py_UNUSED (ignored ))
621
+ filter_reduce (PyObject * self , PyObject * Py_UNUSED (ignored ))
617
622
{
623
+ filterobject * lz = _filterobject_CAST (self );
618
624
return Py_BuildValue ("O(OO)" , Py_TYPE (lz ), lz -> func , lz -> it );
619
625
}
620
626
621
627
PyDoc_STRVAR (reduce_doc , "Return state information for pickling." );
622
628
623
629
static PyMethodDef filter_methods [] = {
624
- {"__reduce__" , _PyCFunction_CAST ( filter_reduce ) , METH_NOARGS , reduce_doc },
630
+ {"__reduce__" , filter_reduce , METH_NOARGS , reduce_doc },
625
631
{NULL , NULL } /* sentinel */
626
632
};
627
633
@@ -638,7 +644,7 @@ PyTypeObject PyFilter_Type = {
638
644
sizeof (filterobject ), /* tp_basicsize */
639
645
0 , /* tp_itemsize */
640
646
/* methods */
641
- ( destructor ) filter_dealloc , /* tp_dealloc */
647
+ filter_dealloc , /* tp_dealloc */
642
648
0 , /* tp_vectorcall_offset */
643
649
0 , /* tp_getattr */
644
650
0 , /* tp_setattr */
@@ -656,12 +662,12 @@ PyTypeObject PyFilter_Type = {
656
662
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
657
663
Py_TPFLAGS_BASETYPE , /* tp_flags */
658
664
filter_doc , /* tp_doc */
659
- ( traverseproc ) filter_traverse , /* tp_traverse */
665
+ filter_traverse , /* tp_traverse */
660
666
0 , /* tp_clear */
661
667
0 , /* tp_richcompare */
662
668
0 , /* tp_weaklistoffset */
663
669
PyObject_SelfIter , /* tp_iter */
664
- ( iternextfunc ) filter_next , /* tp_iternext */
670
+ filter_next , /* tp_iternext */
665
671
filter_methods , /* tp_methods */
666
672
0 , /* tp_members */
667
673
0 , /* tp_getset */
@@ -674,7 +680,7 @@ PyTypeObject PyFilter_Type = {
674
680
PyType_GenericAlloc , /* tp_alloc */
675
681
filter_new , /* tp_new */
676
682
PyObject_GC_Del , /* tp_free */
677
- .tp_vectorcall = ( vectorcallfunc ) filter_vectorcall
683
+ .tp_vectorcall = filter_vectorcall
678
684
};
679
685
680
686
@@ -1319,6 +1325,8 @@ typedef struct {
1319
1325
int strict ;
1320
1326
} mapobject ;
1321
1327
1328
+ #define _mapobject_CAST (op ) ((mapobject *)(op))
1329
+
1322
1330
static PyObject *
1323
1331
map_new (PyTypeObject * type , PyObject * args , PyObject * kwds )
1324
1332
{
@@ -1422,25 +1430,28 @@ map_vectorcall(PyObject *type, PyObject * const*args,
1422
1430
}
1423
1431
1424
1432
static void
1425
- map_dealloc (mapobject * lz )
1433
+ map_dealloc (PyObject * self )
1426
1434
{
1435
+ mapobject * lz = _mapobject_CAST (self );
1427
1436
PyObject_GC_UnTrack (lz );
1428
1437
Py_XDECREF (lz -> iters );
1429
1438
Py_XDECREF (lz -> func );
1430
1439
Py_TYPE (lz )-> tp_free (lz );
1431
1440
}
1432
1441
1433
1442
static int
1434
- map_traverse (mapobject * lz , visitproc visit , void * arg )
1443
+ map_traverse (PyObject * self , visitproc visit , void * arg )
1435
1444
{
1445
+ mapobject * lz = _mapobject_CAST (self );
1436
1446
Py_VISIT (lz -> iters );
1437
1447
Py_VISIT (lz -> func );
1438
1448
return 0 ;
1439
1449
}
1440
1450
1441
1451
static PyObject *
1442
- map_next (mapobject * lz )
1452
+ map_next (PyObject * self )
1443
1453
{
1454
+ mapobject * lz = _mapobject_CAST (self );
1444
1455
Py_ssize_t i ;
1445
1456
PyObject * small_stack [_PY_FASTCALL_SMALL_STACK ];
1446
1457
PyObject * * stack ;
@@ -1523,8 +1534,9 @@ map_next(mapobject *lz)
1523
1534
}
1524
1535
1525
1536
static PyObject *
1526
- map_reduce (mapobject * lz , PyObject * Py_UNUSED (ignored ))
1537
+ map_reduce (PyObject * self , PyObject * Py_UNUSED (ignored ))
1527
1538
{
1539
+ mapobject * lz = _mapobject_CAST (self );
1528
1540
Py_ssize_t numargs = PyTuple_GET_SIZE (lz -> iters );
1529
1541
PyObject * args = PyTuple_New (numargs + 1 );
1530
1542
Py_ssize_t i ;
@@ -1545,19 +1557,20 @@ map_reduce(mapobject *lz, PyObject *Py_UNUSED(ignored))
1545
1557
PyDoc_STRVAR (setstate_doc , "Set state information for unpickling." );
1546
1558
1547
1559
static PyObject *
1548
- map_setstate (mapobject * lz , PyObject * state )
1560
+ map_setstate (PyObject * self , PyObject * state )
1549
1561
{
1550
1562
int strict = PyObject_IsTrue (state );
1551
1563
if (strict < 0 ) {
1552
1564
return NULL ;
1553
1565
}
1566
+ mapobject * lz = _mapobject_CAST (self );
1554
1567
lz -> strict = strict ;
1555
1568
Py_RETURN_NONE ;
1556
1569
}
1557
1570
1558
1571
static PyMethodDef map_methods [] = {
1559
- {"__reduce__" , _PyCFunction_CAST ( map_reduce ) , METH_NOARGS , reduce_doc },
1560
- {"__setstate__" , _PyCFunction_CAST ( map_setstate ) , METH_O , setstate_doc },
1572
+ {"__reduce__" , map_reduce , METH_NOARGS , reduce_doc },
1573
+ {"__setstate__" , map_setstate , METH_O , setstate_doc },
1561
1574
{NULL , NULL } /* sentinel */
1562
1575
};
1563
1576
@@ -1578,7 +1591,7 @@ PyTypeObject PyMap_Type = {
1578
1591
sizeof (mapobject ), /* tp_basicsize */
1579
1592
0 , /* tp_itemsize */
1580
1593
/* methods */
1581
- ( destructor ) map_dealloc , /* tp_dealloc */
1594
+ map_dealloc , /* tp_dealloc */
1582
1595
0 , /* tp_vectorcall_offset */
1583
1596
0 , /* tp_getattr */
1584
1597
0 , /* tp_setattr */
@@ -1596,12 +1609,12 @@ PyTypeObject PyMap_Type = {
1596
1609
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
1597
1610
Py_TPFLAGS_BASETYPE , /* tp_flags */
1598
1611
map_doc , /* tp_doc */
1599
- ( traverseproc ) map_traverse , /* tp_traverse */
1612
+ map_traverse , /* tp_traverse */
1600
1613
0 , /* tp_clear */
1601
1614
0 , /* tp_richcompare */
1602
1615
0 , /* tp_weaklistoffset */
1603
1616
PyObject_SelfIter , /* tp_iter */
1604
- ( iternextfunc ) map_next , /* tp_iternext */
1617
+ map_next , /* tp_iternext */
1605
1618
map_methods , /* tp_methods */
1606
1619
0 , /* tp_members */
1607
1620
0 , /* tp_getset */
@@ -1614,7 +1627,7 @@ PyTypeObject PyMap_Type = {
1614
1627
PyType_GenericAlloc , /* tp_alloc */
1615
1628
map_new , /* tp_new */
1616
1629
PyObject_GC_Del , /* tp_free */
1617
- .tp_vectorcall = ( vectorcallfunc ) map_vectorcall
1630
+ .tp_vectorcall = map_vectorcall
1618
1631
};
1619
1632
1620
1633
@@ -2965,6 +2978,8 @@ typedef struct {
2965
2978
int strict ;
2966
2979
} zipobject ;
2967
2980
2981
+ #define _zipobject_CAST (op ) ((zipobject *)(op))
2982
+
2968
2983
static PyObject *
2969
2984
zip_new (PyTypeObject * type , PyObject * args , PyObject * kwds )
2970
2985
{
@@ -3033,25 +3048,29 @@ zip_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
3033
3048
}
3034
3049
3035
3050
static void
3036
- zip_dealloc (zipobject * lz )
3051
+ zip_dealloc (PyObject * self )
3037
3052
{
3053
+ zipobject * lz = _zipobject_CAST (self );
3038
3054
PyObject_GC_UnTrack (lz );
3039
3055
Py_XDECREF (lz -> ittuple );
3040
3056
Py_XDECREF (lz -> result );
3041
3057
Py_TYPE (lz )-> tp_free (lz );
3042
3058
}
3043
3059
3044
3060
static int
3045
- zip_traverse (zipobject * lz , visitproc visit , void * arg )
3061
+ zip_traverse (PyObject * self , visitproc visit , void * arg )
3046
3062
{
3063
+ zipobject * lz = _zipobject_CAST (self );
3047
3064
Py_VISIT (lz -> ittuple );
3048
3065
Py_VISIT (lz -> result );
3049
3066
return 0 ;
3050
3067
}
3051
3068
3052
3069
static PyObject *
3053
- zip_next (zipobject * lz )
3070
+ zip_next (PyObject * self )
3054
3071
{
3072
+ zipobject * lz = _zipobject_CAST (self );
3073
+
3055
3074
Py_ssize_t i ;
3056
3075
Py_ssize_t tuplesize = lz -> tuplesize ;
3057
3076
PyObject * result = lz -> result ;
@@ -3141,8 +3160,9 @@ zip_next(zipobject *lz)
3141
3160
}
3142
3161
3143
3162
static PyObject *
3144
- zip_reduce (zipobject * lz , PyObject * Py_UNUSED (ignored ))
3163
+ zip_reduce (PyObject * self , PyObject * Py_UNUSED (ignored ))
3145
3164
{
3165
+ zipobject * lz = _zipobject_CAST (self );
3146
3166
/* Just recreate the zip with the internal iterator tuple */
3147
3167
if (lz -> strict ) {
3148
3168
return PyTuple_Pack (3 , Py_TYPE (lz ), lz -> ittuple , Py_True );
@@ -3151,19 +3171,20 @@ zip_reduce(zipobject *lz, PyObject *Py_UNUSED(ignored))
3151
3171
}
3152
3172
3153
3173
static PyObject *
3154
- zip_setstate (zipobject * lz , PyObject * state )
3174
+ zip_setstate (PyObject * self , PyObject * state )
3155
3175
{
3156
3176
int strict = PyObject_IsTrue (state );
3157
3177
if (strict < 0 ) {
3158
3178
return NULL ;
3159
3179
}
3180
+ zipobject * lz = _zipobject_CAST (self );
3160
3181
lz -> strict = strict ;
3161
3182
Py_RETURN_NONE ;
3162
3183
}
3163
3184
3164
3185
static PyMethodDef zip_methods [] = {
3165
- {"__reduce__" , _PyCFunction_CAST ( zip_reduce ) , METH_NOARGS , reduce_doc },
3166
- {"__setstate__" , _PyCFunction_CAST ( zip_setstate ) , METH_O , setstate_doc },
3186
+ {"__reduce__" , zip_reduce , METH_NOARGS , reduce_doc },
3187
+ {"__setstate__" , zip_setstate , METH_O , setstate_doc },
3167
3188
{NULL } /* sentinel */
3168
3189
};
3169
3190
@@ -3188,7 +3209,7 @@ PyTypeObject PyZip_Type = {
3188
3209
sizeof (zipobject ), /* tp_basicsize */
3189
3210
0 , /* tp_itemsize */
3190
3211
/* methods */
3191
- ( destructor ) zip_dealloc , /* tp_dealloc */
3212
+ zip_dealloc , /* tp_dealloc */
3192
3213
0 , /* tp_vectorcall_offset */
3193
3214
0 , /* tp_getattr */
3194
3215
0 , /* tp_setattr */
@@ -3206,12 +3227,12 @@ PyTypeObject PyZip_Type = {
3206
3227
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
3207
3228
Py_TPFLAGS_BASETYPE , /* tp_flags */
3208
3229
zip_doc , /* tp_doc */
3209
- ( traverseproc ) zip_traverse , /* tp_traverse */
3230
+ zip_traverse , /* tp_traverse */
3210
3231
0 , /* tp_clear */
3211
3232
0 , /* tp_richcompare */
3212
3233
0 , /* tp_weaklistoffset */
3213
3234
PyObject_SelfIter , /* tp_iter */
3214
- ( iternextfunc ) zip_next , /* tp_iternext */
3235
+ zip_next , /* tp_iternext */
3215
3236
zip_methods , /* tp_methods */
3216
3237
0 , /* tp_members */
3217
3238
0 , /* tp_getset */
0 commit comments