@@ -272,6 +272,21 @@ _bz2_BZ2Compressor_flush_impl(BZ2Compressor *self)
272
272
return result ;
273
273
}
274
274
275
+ /*[clinic input]
276
+ _bz2.BZ2Compressor.__reduce__ as _bz2_compressor_reduce
277
+
278
+ [clinic start generated code]*/
279
+
280
+ static PyObject *
281
+ _bz2_compressor_reduce_impl (BZ2Compressor * self )
282
+ /*[clinic end generated code: output=8b4e32a4a405409b input=598cfb30699bd0ee]*/
283
+ {
284
+ PyErr_Format (PyExc_TypeError ,
285
+ "cannot pickle %s object" ,
286
+ Py_TYPE (self )-> tp_name );
287
+ return NULL ;
288
+ }
289
+
275
290
static void *
276
291
BZ2_Malloc (void * ctx , int items , int size )
277
292
{
@@ -378,13 +393,15 @@ BZ2Compressor_dealloc(BZ2Compressor *self)
378
393
static PyMethodDef BZ2Compressor_methods [] = {
379
394
_BZ2_BZ2COMPRESSOR_COMPRESS_METHODDEF
380
395
_BZ2_BZ2COMPRESSOR_FLUSH_METHODDEF
396
+ _BZ2_COMPRESSOR_REDUCE_METHODDEF
381
397
{NULL }
382
398
};
383
399
384
400
static PyType_Slot bz2_compressor_type_slots [] = {
385
401
{Py_tp_dealloc , BZ2Compressor_dealloc },
386
402
{Py_tp_methods , BZ2Compressor_methods },
387
403
{Py_tp_init , _bz2_BZ2Compressor___init__ },
404
+ {Py_tp_new , PyType_GenericNew },
388
405
{Py_tp_doc , (char * )_bz2_BZ2Compressor___init____doc__ },
389
406
{0 , 0 }
390
407
};
@@ -396,7 +413,7 @@ static PyType_Spec bz2_compressor_type_spec = {
396
413
// dbmtype_spec does not have Py_TPFLAGS_BASETYPE flag
397
414
// which prevents to create a subclass.
398
415
// So calling PyType_GetModuleState() in this file is always safe.
399
- .flags = Py_TPFLAGS_DEFAULT ,
416
+ .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE ,
400
417
.slots = bz2_compressor_type_slots ,
401
418
};
402
419
@@ -618,6 +635,21 @@ _bz2_BZ2Decompressor_decompress_impl(BZ2Decompressor *self, Py_buffer *data,
618
635
return result ;
619
636
}
620
637
638
+ /*[clinic input]
639
+ _bz2.BZ2Decompressor.__reduce__ as _bz2_decompressor_reduce
640
+
641
+ [clinic start generated code]*/
642
+
643
+ static PyObject *
644
+ _bz2_decompressor_reduce_impl (BZ2Decompressor * self )
645
+ /*[clinic end generated code: output=c79772d813bf4271 input=486b9c8c0205e116]*/
646
+ {
647
+ PyErr_Format (PyExc_TypeError ,
648
+ "cannot pickle %s object" ,
649
+ Py_TYPE (self )-> tp_name );
650
+ return NULL ;
651
+ }
652
+
621
653
// TODO: Convert it to clinic
622
654
static int
623
655
_bz2_BZ2Decompressor___init___impl (BZ2Decompressor * self )
@@ -703,6 +735,7 @@ BZ2Decompressor_dealloc(BZ2Decompressor *self)
703
735
704
736
static PyMethodDef BZ2Decompressor_methods [] = {
705
737
_BZ2_BZ2DECOMPRESSOR_DECOMPRESS_METHODDEF
738
+ _BZ2_DECOMPRESSOR_REDUCE_METHODDEF
706
739
{NULL }
707
740
};
708
741
@@ -731,6 +764,7 @@ static PyType_Slot bz2_decompressor_type_slots[] = {
731
764
{Py_tp_init , _bz2_BZ2Decompressor___init__ },
732
765
{Py_tp_doc , (char * )_bz2_BZ2Decompressor___init____doc__ },
733
766
{Py_tp_members , BZ2Decompressor_members },
767
+ {Py_tp_new , PyType_GenericNew },
734
768
{0 , 0 }
735
769
};
736
770
0 commit comments