Skip to content

Commit 60b1d76

Browse files
committed
Simplify decompress.decompress parser
1 parent cda92a9 commit 60b1d76

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

src/isal/isal_zlib.c

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -971,30 +971,23 @@ PyDoc_STRVAR(isal_zlib_Decompress_decompress__doc__,
971971
"Call the flush() method to clear these buffers.");
972972

973973
#define ISAL_ZLIB_DECOMPRESS_DECOMPRESS_METHODDEF \
974-
{"decompress", (PyCFunction)(void(*)(void))isal_zlib_Decompress_decompress, METH_FASTCALL|METH_KEYWORDS, isal_zlib_Decompress_decompress__doc__}
974+
{"decompress", (PyCFunction)(void(*)(void))isal_zlib_Decompress_decompress, METH_VARARGS|METH_KEYWORDS, isal_zlib_Decompress_decompress__doc__}
975975

976976

977977
static PyObject *
978-
isal_zlib_Decompress_decompress(decompobject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
978+
isal_zlib_Decompress_decompress(decompobject *self, PyObject *args, PyObject *kwargs)
979979
{
980-
PyObject *return_value = NULL;
981-
static const char * const _keywords[] = {"", "max_length", NULL};
982-
static _PyArg_Parser _parser = {"y*|n:decompress", _keywords, 0};
980+
char *keywords[] = {"", "max_length", NULL};
981+
char *format = "y*|n:decompress";
982+
983983
Py_buffer data = {NULL, NULL};
984984
Py_ssize_t max_length = 0;
985-
986-
if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
987-
&data, &max_length)) {
988-
goto exit;
989-
}
990-
return_value = isal_zlib_Decompress_decompress_impl(self, &data, max_length);
991-
992-
exit:
993-
/* Cleanup for data */
994-
if (data.obj) {
995-
PyBuffer_Release(&data);
985+
if (!PyArg_ParseTupleAndKeywords(
986+
args, kwargs, format, keywords, &data, &max_length)) {
987+
return NULL;
996988
}
997-
989+
PyObject *return_value = isal_zlib_Decompress_decompress_impl(self, &data, max_length);
990+
PyBuffer_Release(&data);
998991
return return_value;
999992
}
1000993

0 commit comments

Comments
 (0)