@@ -315,77 +315,27 @@ PyDoc_STRVAR(igzip_lib_compress__doc__,
315
315
" the header and trailer are controlled by the flag parameter." );
316
316
317
317
#define IGZIP_LIB_COMPRESS_METHODDEF \
318
- {"compress", (PyCFunction)(void(*)(void))igzip_lib_compress, METH_FASTCALL |METH_KEYWORDS, igzip_lib_compress__doc__}
318
+ {"compress", (PyCFunction)(void(*)(void))igzip_lib_compress, METH_VARARGS |METH_KEYWORDS, igzip_lib_compress__doc__}
319
319
320
320
static PyObject *
321
- igzip_lib_compress (PyObject * module , PyObject * const * args , Py_ssize_t nargs , PyObject * kwnames )
321
+ igzip_lib_compress (PyObject * module , PyObject * args , PyObject * kwargs )
322
322
{
323
- PyObject * return_value = NULL ;
324
- static const char * const _keywords [] = {"" , "level" , "flag" , "mem_level" , "hist_bits" , NULL };
325
- static _PyArg_Parser _parser = {NULL , _keywords , "compress" , 0 };
326
- PyObject * argsbuf [5 ];
327
- Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE (kwnames ) : 0 ) - 1 ;
323
+ char * keywords [] = {"" , "level" , "flag" , "mem_level" , "hist_bits" , NULL };
324
+ char * format = "y*|iiii:compress" ;
328
325
Py_buffer data = {NULL , NULL };
329
326
int level = ISAL_DEFAULT_COMPRESSION ;
330
327
int flag = COMP_DEFLATE ;
331
328
int mem_level = MEM_LEVEL_DEFAULT ;
332
329
int hist_bits = ISAL_DEF_MAX_HIST_BITS ;
333
330
334
- args = _PyArg_UnpackKeywords (args , nargs , NULL , kwnames , & _parser , 1 , 5 , 0 , argsbuf );
335
- if (!args ) {
336
- goto exit ;
337
- }
338
- if (PyObject_GetBuffer (args [0 ], & data , PyBUF_SIMPLE ) != 0 ) {
339
- goto exit ;
340
- }
341
- if (!PyBuffer_IsContiguous (& data , 'C' )) {
342
- _PyArg_BadArgument ("compress" , "argument 1" , "contiguous buffer" , args [0 ]);
343
- goto exit ;
344
- }
345
- if (!noptargs ) {
346
- goto skip_optional_pos ;
347
- }
348
- if (args [1 ]) {
349
- level = _PyLong_AsInt (args [1 ]);
350
- if (level == -1 && PyErr_Occurred ()) {
351
- goto exit ;
352
- }
353
- if (!-- noptargs ) {
354
- goto skip_optional_pos ;
355
- }
356
- }
357
- if (args [2 ]) {
358
- flag = _PyLong_AsInt (args [2 ]);
359
- if (flag == -1 && PyErr_Occurred ()) {
360
- goto exit ;
361
- }
362
- if (!-- noptargs ) {
363
- goto skip_optional_pos ;
364
- }
365
- }
366
- if (args [3 ]) {
367
- mem_level = _PyLong_AsInt (args [3 ]);
368
- if (mem_level == -1 && PyErr_Occurred ()) {
369
- goto exit ;
370
- }
371
- if (!-- noptargs ) {
372
- goto skip_optional_pos ;
373
- }
374
- }
375
- hist_bits = _PyLong_AsInt (args [4 ]);
376
- if (hist_bits == -1 && PyErr_Occurred ()) {
377
- goto exit ;
331
+ if (!PyArg_ParseTupleAndKeywords (
332
+ args , kwargs , format , keywords ,
333
+ & data , & level , & flag , & mem_level , & hist_bits )) {
334
+ return NULL ;
378
335
}
379
- skip_optional_pos :
380
- return_value = igzip_lib_compress_impl (
336
+ PyObject * return_value = igzip_lib_compress_impl (
381
337
& data , level , flag , mem_level , hist_bits );
382
-
383
- exit :
384
- /* Cleanup for data */
385
- if (data .obj ) {
386
- PyBuffer_Release (& data );
387
- }
388
-
338
+ PyBuffer_Release (& data );
389
339
return return_value ;
390
340
}
391
341
0 commit comments