@@ -381,13 +381,14 @@ _bz2_BZ2Compressor_impl(PyTypeObject *type, int compresslevel)
381
381
static void
382
382
BZ2Compressor_dealloc (PyObject * op )
383
383
{
384
+ PyTypeObject * tp = Py_TYPE (op );
385
+ PyObject_GC_UnTrack (op );
384
386
BZ2Compressor * self = _BZ2Compressor_CAST (op );
385
387
BZ2_bzCompressEnd (& self -> bzs );
386
388
if (self -> lock != NULL ) {
387
389
PyThread_free_lock (self -> lock );
388
390
}
389
- PyTypeObject * tp = Py_TYPE (self );
390
- tp -> tp_free ((PyObject * )self );
391
+ tp -> tp_free (self );
391
392
Py_DECREF (tp );
392
393
}
393
394
@@ -420,7 +421,7 @@ static PyType_Spec bz2_compressor_type_spec = {
420
421
// bz2_compressor_type_spec does not have Py_TPFLAGS_BASETYPE flag
421
422
// which prevents to create a subclass.
422
423
// So calling PyType_GetModuleState() in this file is always safe.
423
- .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE ),
424
+ .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_HAVE_GC ),
424
425
.slots = bz2_compressor_type_slots ,
425
426
};
426
427
@@ -687,19 +688,19 @@ _bz2_BZ2Decompressor_impl(PyTypeObject *type)
687
688
static void
688
689
BZ2Decompressor_dealloc (PyObject * op )
689
690
{
691
+ PyTypeObject * tp = Py_TYPE (op );
692
+ PyObject_GC_UnTrack (op );
690
693
BZ2Decompressor * self = _BZ2Decompressor_CAST (op );
691
694
692
- if (self -> input_buffer != NULL ) {
695
+ if (self -> input_buffer != NULL ) {
693
696
PyMem_Free (self -> input_buffer );
694
697
}
695
698
BZ2_bzDecompressEnd (& self -> bzs );
696
699
Py_CLEAR (self -> unused_data );
697
700
if (self -> lock != NULL ) {
698
701
PyThread_free_lock (self -> lock );
699
702
}
700
-
701
- PyTypeObject * tp = Py_TYPE (self );
702
- tp -> tp_free ((PyObject * )self );
703
+ tp -> tp_free (self );
703
704
Py_DECREF (tp );
704
705
}
705
706
@@ -751,7 +752,7 @@ static PyType_Spec bz2_decompressor_type_spec = {
751
752
// bz2_decompressor_type_spec does not have Py_TPFLAGS_BASETYPE flag
752
753
// which prevents to create a subclass.
753
754
// So calling PyType_GetModuleState() in this file is always safe.
754
- .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE ),
755
+ .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_HAVE_GC ),
755
756
.slots = bz2_decompressor_type_slots ,
756
757
};
757
758
0 commit comments