@@ -1004,19 +1004,27 @@ itemgetter_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
1004
1004
return (PyObject * )ig ;
1005
1005
}
1006
1006
1007
+ static int
1008
+ itemgetter_clear (itemgetterobject * ig )
1009
+ {
1010
+ Py_CLEAR (ig -> item );
1011
+ return 0 ;
1012
+ }
1013
+
1007
1014
static void
1008
1015
itemgetter_dealloc (itemgetterobject * ig )
1009
1016
{
1010
1017
PyTypeObject * tp = Py_TYPE (ig );
1011
1018
PyObject_GC_UnTrack (ig );
1012
- Py_XDECREF ( ig -> item );
1019
+ ( void ) itemgetter_clear ( ig );
1013
1020
tp -> tp_free (ig );
1014
1021
Py_DECREF (tp );
1015
1022
}
1016
1023
1017
1024
static int
1018
1025
itemgetter_traverse (itemgetterobject * ig , visitproc visit , void * arg )
1019
1026
{
1027
+ Py_VISIT (Py_TYPE (ig ));
1020
1028
Py_VISIT (ig -> item );
1021
1029
return 0 ;
1022
1030
}
@@ -1113,6 +1121,7 @@ static PyType_Slot itemgetter_type_slots[] = {
1113
1121
{Py_tp_dealloc , itemgetter_dealloc },
1114
1122
{Py_tp_call , itemgetter_call },
1115
1123
{Py_tp_traverse , itemgetter_traverse },
1124
+ {Py_tp_clear , itemgetter_clear },
1116
1125
{Py_tp_methods , itemgetter_methods },
1117
1126
{Py_tp_new , itemgetter_new },
1118
1127
{Py_tp_getattro , PyObject_GenericGetAttr },
@@ -1250,12 +1259,19 @@ attrgetter_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
1250
1259
return (PyObject * )ag ;
1251
1260
}
1252
1261
1262
+ static int
1263
+ attrgetter_clear (attrgetterobject * ag )
1264
+ {
1265
+ Py_CLEAR (ag -> attr );
1266
+ return 0 ;
1267
+ }
1268
+
1253
1269
static void
1254
1270
attrgetter_dealloc (attrgetterobject * ag )
1255
1271
{
1256
1272
PyTypeObject * tp = Py_TYPE (ag );
1257
1273
PyObject_GC_UnTrack (ag );
1258
- Py_XDECREF ( ag -> attr );
1274
+ ( void ) attrgetter_clear ( ag );
1259
1275
tp -> tp_free (ag );
1260
1276
Py_DECREF (tp );
1261
1277
}
@@ -1264,6 +1280,7 @@ static int
1264
1280
attrgetter_traverse (attrgetterobject * ag , visitproc visit , void * arg )
1265
1281
{
1266
1282
Py_VISIT (ag -> attr );
1283
+ Py_VISIT (Py_TYPE (ag ));
1267
1284
return 0 ;
1268
1285
}
1269
1286
@@ -1435,6 +1452,7 @@ static PyType_Slot attrgetter_type_slots[] = {
1435
1452
{Py_tp_dealloc , attrgetter_dealloc },
1436
1453
{Py_tp_call , attrgetter_call },
1437
1454
{Py_tp_traverse , attrgetter_traverse },
1455
+ {Py_tp_clear , attrgetter_clear },
1438
1456
{Py_tp_methods , attrgetter_methods },
1439
1457
{Py_tp_new , attrgetter_new },
1440
1458
{Py_tp_getattro , PyObject_GenericGetAttr },
@@ -1505,23 +1523,32 @@ methodcaller_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
1505
1523
return (PyObject * )mc ;
1506
1524
}
1507
1525
1526
+ static int
1527
+ methodcaller_clear (methodcallerobject * mc )
1528
+ {
1529
+ Py_CLEAR (mc -> name );
1530
+ Py_CLEAR (mc -> args );
1531
+ Py_CLEAR (mc -> kwds );
1532
+ return 0 ;
1533
+ }
1534
+
1508
1535
static void
1509
1536
methodcaller_dealloc (methodcallerobject * mc )
1510
1537
{
1511
1538
PyTypeObject * tp = Py_TYPE (mc );
1512
1539
PyObject_GC_UnTrack (mc );
1513
- Py_XDECREF (mc -> name );
1514
- Py_XDECREF (mc -> args );
1515
- Py_XDECREF (mc -> kwds );
1540
+ (void )methodcaller_clear (mc );
1516
1541
tp -> tp_free (mc );
1517
1542
Py_DECREF (tp );
1518
1543
}
1519
1544
1520
1545
static int
1521
1546
methodcaller_traverse (methodcallerobject * mc , visitproc visit , void * arg )
1522
1547
{
1548
+ Py_VISIT (mc -> name );
1523
1549
Py_VISIT (mc -> args );
1524
1550
Py_VISIT (mc -> kwds );
1551
+ Py_VISIT (Py_TYPE (mc ));
1525
1552
return 0 ;
1526
1553
}
1527
1554
@@ -1680,6 +1707,7 @@ static PyType_Slot methodcaller_type_slots[] = {
1680
1707
{Py_tp_dealloc , methodcaller_dealloc },
1681
1708
{Py_tp_call , methodcaller_call },
1682
1709
{Py_tp_traverse , methodcaller_traverse },
1710
+ {Py_tp_clear , methodcaller_clear },
1683
1711
{Py_tp_methods , methodcaller_methods },
1684
1712
{Py_tp_new , methodcaller_new },
1685
1713
{Py_tp_getattro , PyObject_GenericGetAttr },
0 commit comments