@@ -315,6 +315,7 @@ static PyGetSetDef Dialect_getsetlist[] = {
315
315
static void
316
316
Dialect_dealloc (DialectObj * self )
317
317
{
318
+ PyObject_GC_UnTrack (self );
318
319
PyTypeObject * tp = Py_TYPE (self );
319
320
Py_CLEAR (self -> lineterminator );
320
321
tp -> tp_free ((PyObject * )self );
@@ -512,6 +513,13 @@ PyDoc_STRVAR(Dialect_Type_doc,
512
513
"\n"
513
514
"The Dialect type records CSV parsing and generation options.\n" );
514
515
516
+ static int
517
+ Dialect_traverse (PyObject * self , visitproc visit , void * arg )
518
+ {
519
+ Py_VISIT (Py_TYPE (self ));
520
+ return 0 ;
521
+ }
522
+
515
523
static PyType_Slot Dialect_Type_slots [] = {
516
524
{Py_tp_doc , (char * )Dialect_Type_doc },
517
525
{Py_tp_members , Dialect_memberlist },
@@ -520,13 +528,14 @@ static PyType_Slot Dialect_Type_slots[] = {
520
528
{Py_tp_methods , dialect_methods },
521
529
{Py_tp_finalize , Dialect_finalize },
522
530
{Py_tp_dealloc , Dialect_dealloc },
531
+ {Py_tp_traverse , Dialect_traverse },
523
532
{0 , NULL }
524
533
};
525
534
526
535
PyType_Spec Dialect_Type_spec = {
527
536
.name = "_csv.Dialect" ,
528
537
.basicsize = sizeof (DialectObj ),
529
- .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE ,
538
+ .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC ,
530
539
.slots = Dialect_Type_slots ,
531
540
};
532
541
@@ -914,6 +923,7 @@ Reader_traverse(ReaderObj *self, visitproc visit, void *arg)
914
923
Py_VISIT (self -> dialect );
915
924
Py_VISIT (self -> input_iter );
916
925
Py_VISIT (self -> fields );
926
+ Py_VISIT (Py_TYPE (self ));
917
927
return 0 ;
918
928
}
919
929
@@ -1339,6 +1349,7 @@ Writer_traverse(WriterObj *self, visitproc visit, void *arg)
1339
1349
Py_VISIT (self -> dialect );
1340
1350
Py_VISIT (self -> write );
1341
1351
Py_VISIT (self -> error_obj );
1352
+ Py_VISIT (Py_TYPE (self ));
1342
1353
return 0 ;
1343
1354
}
1344
1355
@@ -1351,6 +1362,15 @@ Writer_clear(WriterObj *self)
1351
1362
return 0 ;
1352
1363
}
1353
1364
1365
+ static void
1366
+ Writer_dealloc (WriterObj * self )
1367
+ {
1368
+ PyObject_GC_UnTrack (self );
1369
+ PyTypeObject * tp = Py_TYPE (self );
1370
+ tp -> tp_clear ((PyObject * )self );
1371
+ Py_DECREF (tp );
1372
+ }
1373
+
1354
1374
static void
1355
1375
Writer_finalize (WriterObj * self )
1356
1376
{
@@ -1372,6 +1392,7 @@ static PyType_Slot Writer_Type_slots[] = {
1372
1392
{Py_tp_doc , (char * )Writer_Type_doc },
1373
1393
{Py_tp_traverse , Writer_traverse },
1374
1394
{Py_tp_clear , Writer_clear },
1395
+ {Py_tp_dealloc , Writer_dealloc },
1375
1396
{Py_tp_methods , Writer_methods },
1376
1397
{Py_tp_members , Writer_memberlist },
1377
1398
{0 , NULL }
@@ -1509,13 +1530,31 @@ csv_field_size_limit(PyObject *module, PyObject *args)
1509
1530
return PyLong_FromLong (old_limit );
1510
1531
}
1511
1532
1533
+ static void
1534
+ error_dealloc (PyObject * self )
1535
+ {
1536
+ PyObject_GC_UnTrack (self );
1537
+ PyTypeObject * tp = Py_TYPE (self );
1538
+ tp -> tp_free ((PyObject * )self );
1539
+ Py_DECREF (tp );
1540
+ }
1541
+
1542
+ static int
1543
+ error_traverse (PyObject * self , visitproc visit , void * arg )
1544
+ {
1545
+ Py_VISIT (Py_TYPE (self ));
1546
+ return 0 ;
1547
+ }
1548
+
1512
1549
static PyType_Slot error_slots [] = {
1550
+ {Py_tp_traverse , error_traverse },
1551
+ {Py_tp_dealloc , error_dealloc },
1513
1552
{0 , NULL },
1514
1553
};
1515
1554
1516
1555
PyType_Spec error_spec = {
1517
1556
.name = "_csv.Error" ,
1518
- .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE ,
1557
+ .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC ,
1519
1558
.slots = error_slots ,
1520
1559
};
1521
1560
0 commit comments