@@ -356,83 +356,25 @@ PyDoc_STRVAR(igzip_lib_decompress__doc__,
356
356
" The initial output buffer size." );
357
357
358
358
#define IGZIP_LIB_DECOMPRESS_METHODDEF \
359
- {"decompress", (PyCFunction)(void(*)(void))igzip_lib_decompress, METH_FASTCALL |METH_KEYWORDS, igzip_lib_decompress__doc__}
359
+ {"decompress", (PyCFunction)(void(*)(void))igzip_lib_decompress, METH_VARARGS |METH_KEYWORDS, igzip_lib_decompress__doc__}
360
360
361
361
static PyObject *
362
- igzip_lib_decompress (PyObject * module , PyObject * const * args , Py_ssize_t nargs , PyObject * kwnames )
362
+ igzip_lib_decompress (PyObject * module , PyObject * args , PyObject * kwargs )
363
363
{
364
- PyObject * return_value = NULL ;
365
- static const char * const _keywords [] = {"" , "flag" , "hist_bits" , "bufsize" , NULL };
366
- static _PyArg_Parser _parser = {NULL , _keywords , "decompress" , 0 };
367
- PyObject * argsbuf [4 ];
368
- Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE (kwnames ) : 0 ) - 1 ;
364
+ static const char * keywords [] = {"" , "flag" , "hist_bits" , "bufsize" , NULL };
365
+ char * format = "y*|iin:decompress" ;
369
366
Py_buffer data = {NULL , NULL };
370
367
int flag = DECOMP_DEFLATE ;
371
368
int hist_bits = ISAL_DEF_MAX_HIST_BITS ;
372
369
Py_ssize_t bufsize = DEF_BUF_SIZE ;
373
370
374
- args = _PyArg_UnpackKeywords (args , nargs , NULL , kwnames , & _parser , 1 , 4 , 0 , argsbuf );
375
- if (!args ) {
376
- goto exit ;
377
- }
378
- if (PyObject_GetBuffer (args [0 ], & data , PyBUF_SIMPLE ) != 0 ) {
379
- goto exit ;
380
- }
381
- if (!PyBuffer_IsContiguous (& data , 'C' )) {
382
- _PyArg_BadArgument ("decompress" , "argument 1" , "contiguous buffer" , args [0 ]);
383
- goto exit ;
384
- }
385
- if (!noptargs ) {
386
- goto skip_optional_pos ;
387
- }
388
- if (args [1 ]) {
389
- flag = _PyLong_AsInt (args [1 ]);
390
- if (flag == -1 && PyErr_Occurred ()) {
391
- goto exit ;
392
- }
393
- if (!-- noptargs ) {
394
- goto skip_optional_pos ;
395
- }
396
- }
397
- if (args [2 ]) {
398
- hist_bits = _PyLong_AsInt (args [2 ]);
399
- if (hist_bits == -1 && PyErr_Occurred ()) {
400
- goto exit ;
401
- }
402
- if (!-- noptargs ) {
403
- goto skip_optional_pos ;
404
- }
405
- }
406
- if (args [2 ]) {
407
- flag = _PyLong_AsInt (args [2 ]);
408
- if (flag == -1 && PyErr_Occurred ()) {
409
- goto exit ;
410
- }
411
- if (!-- noptargs ) {
412
- goto skip_optional_pos ;
413
- }
414
- }
415
- {
416
- Py_ssize_t ival = -1 ;
417
- PyObject * iobj = PyNumber_Index (args [3 ]);
418
- if (iobj != NULL ) {
419
- ival = PyLong_AsSsize_t (iobj );
420
- Py_DECREF (iobj );
421
- }
422
- if (ival == -1 && PyErr_Occurred ()) {
423
- goto exit ;
424
- }
425
- bufsize = ival ;
426
- }
427
- skip_optional_pos :
428
- return_value = igzip_lib_decompress_impl (& data , flag , hist_bits , bufsize );
429
-
430
- exit :
431
- /* Cleanup for data */
432
- if (data .obj ) {
433
- PyBuffer_Release (& data );
371
+ if (!PyArg_ParseTupleAndKeywords (
372
+ args , kwargs , format , keywords ,
373
+ & data , & flag , & hist_bits , & bufsize )) {
374
+ return NULL ;
434
375
}
435
-
376
+ PyObject * return_value = igzip_lib_decompress_impl (& data , flag , hist_bits , bufsize );
377
+ PyBuffer_Release (& data );
436
378
return return_value ;
437
379
}
438
380
0 commit comments