@@ -352,13 +352,10 @@ _bz2_BZ2Compressor_impl(PyTypeObject *type, int compresslevel)
352352 }
353353
354354 assert (type != NULL && type -> tp_alloc != NULL );
355- self = PyObject_GC_New (BZ2Compressor , type );
355+ self = (BZ2Compressor * ) type -> tp_alloc ( type , 0 );
356356 if (self == NULL ) {
357357 return NULL ;
358358 }
359- /* Initialize the remaining fields (untouched by PyObject_GC_New()). */
360- const size_t offset = sizeof (struct { PyObject_HEAD });
361- memset ((char * )self + offset , 0 , sizeof (* self ) - offset );
362359
363360 self -> lock = PyThread_allocate_lock ();
364361 if (self -> lock == NULL ) {
@@ -657,14 +654,11 @@ _bz2_BZ2Decompressor_impl(PyTypeObject *type)
657654 BZ2Decompressor * self ;
658655 int bzerror ;
659656
660- assert (type != NULL );
661- self = PyObject_GC_New (BZ2Decompressor , type );
657+ assert (type != NULL && type -> tp_alloc != NULL );
658+ self = (BZ2Decompressor * ) type -> tp_alloc ( type , 0 );
662659 if (self == NULL ) {
663660 return NULL ;
664661 }
665- /* Initialize the remaining fields (untouched by PyObject_GC_New()). */
666- const size_t offset = sizeof (struct { PyObject_HEAD });
667- memset ((char * )self + offset , 0 , sizeof (* self ) - offset );
668662
669663 self -> lock = PyThread_allocate_lock ();
670664 if (self -> lock == NULL ) {
@@ -674,6 +668,9 @@ _bz2_BZ2Decompressor_impl(PyTypeObject *type)
674668 }
675669
676670 self -> needs_input = 1 ;
671+ self -> bzs_avail_in_real = 0 ;
672+ self -> input_buffer = NULL ;
673+ self -> input_buffer_size = 0 ;
677674 self -> unused_data = PyBytes_FromStringAndSize (NULL , 0 );
678675 if (self -> unused_data == NULL )
679676 goto error ;
0 commit comments