@@ -129,9 +129,6 @@ typedef struct {
129129 PyThread_type_lock lock ;
130130} BZ2Decompressor ;
131131
132- #define _BZ2Compressor_CAST (op ) ((BZ2Compressor *)(op))
133- #define _BZ2Decompressor_CAST (op ) ((BZ2Decompressor *)(op))
134-
135132/* Helper functions. */
136133
137134static int
@@ -379,21 +376,19 @@ _bz2_BZ2Compressor_impl(PyTypeObject *type, int compresslevel)
379376}
380377
381378static void
382- BZ2Compressor_dealloc (PyObject * op )
379+ BZ2Compressor_dealloc (BZ2Compressor * self )
383380{
384- PyTypeObject * tp = Py_TYPE (op );
385- PyObject_GC_UnTrack (op );
386- BZ2Compressor * self = _BZ2Compressor_CAST (op );
387381 BZ2_bzCompressEnd (& self -> bzs );
388382 if (self -> lock != NULL ) {
389383 PyThread_free_lock (self -> lock );
390384 }
391- tp -> tp_free (self );
385+ PyTypeObject * tp = Py_TYPE (self );
386+ tp -> tp_free ((PyObject * )self );
392387 Py_DECREF (tp );
393388}
394389
395390static int
396- BZ2Compressor_traverse (PyObject * self , visitproc visit , void * arg )
391+ BZ2Compressor_traverse (BZ2Compressor * self , visitproc visit , void * arg )
397392{
398393 Py_VISIT (Py_TYPE (self ));
399394 return 0 ;
@@ -421,7 +416,7 @@ static PyType_Spec bz2_compressor_type_spec = {
421416 // bz2_compressor_type_spec does not have Py_TPFLAGS_BASETYPE flag
422417 // which prevents to create a subclass.
423418 // So calling PyType_GetModuleState() in this file is always safe.
424- .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_HAVE_GC ),
419+ .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE ),
425420 .slots = bz2_compressor_type_slots ,
426421};
427422
@@ -685,11 +680,8 @@ _bz2_BZ2Decompressor_impl(PyTypeObject *type)
685680}
686681
687682static void
688- BZ2Decompressor_dealloc (PyObject * op )
683+ BZ2Decompressor_dealloc (BZ2Decompressor * self )
689684{
690- PyTypeObject * tp = Py_TYPE (op );
691- PyObject_GC_UnTrack (op );
692- BZ2Decompressor * self = _BZ2Decompressor_CAST (op );
693685 if (self -> input_buffer != NULL ) {
694686 PyMem_Free (self -> input_buffer );
695687 }
@@ -698,12 +690,14 @@ BZ2Decompressor_dealloc(PyObject *op)
698690 if (self -> lock != NULL ) {
699691 PyThread_free_lock (self -> lock );
700692 }
701- tp -> tp_free (self );
693+
694+ PyTypeObject * tp = Py_TYPE (self );
695+ tp -> tp_free ((PyObject * )self );
702696 Py_DECREF (tp );
703697}
704698
705699static int
706- BZ2Decompressor_traverse (PyObject * self , visitproc visit , void * arg )
700+ BZ2Decompressor_traverse (BZ2Decompressor * self , visitproc visit , void * arg )
707701{
708702 Py_VISIT (Py_TYPE (self ));
709703 return 0 ;
@@ -750,7 +744,7 @@ static PyType_Spec bz2_decompressor_type_spec = {
750744 // bz2_decompressor_type_spec does not have Py_TPFLAGS_BASETYPE flag
751745 // which prevents to create a subclass.
752746 // So calling PyType_GetModuleState() in this file is always safe.
753- .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_HAVE_GC ),
747+ .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE ),
754748 .slots = bz2_decompressor_type_slots ,
755749};
756750
0 commit comments