diff options
Diffstat (limited to 'Modules/clinic/zlibmodule.c.h')
-rw-r--r-- | Modules/clinic/zlibmodule.c.h | 76 |
1 files changed, 47 insertions, 29 deletions
diff --git a/Modules/clinic/zlibmodule.c.h b/Modules/clinic/zlibmodule.c.h index 71da0273a7..1b2b7fed46 100644 --- a/Modules/clinic/zlibmodule.c.h +++ b/Modules/clinic/zlibmodule.c.h @@ -3,38 +3,41 @@ preserve [clinic start generated code]*/ PyDoc_STRVAR(zlib_compress__doc__, -"compress($module, bytes, level=Z_DEFAULT_COMPRESSION, /)\n" +"compress($module, data, /, level=Z_DEFAULT_COMPRESSION)\n" "--\n" "\n" "Returns a bytes object containing compressed data.\n" "\n" -" bytes\n" +" data\n" " Binary data to be compressed.\n" " level\n" -" Compression level, in 0-9."); +" Compression level, in 0-9 or -1."); #define ZLIB_COMPRESS_METHODDEF \ - {"compress", (PyCFunction)zlib_compress, METH_VARARGS, zlib_compress__doc__}, + {"compress", (PyCFunction)zlib_compress, METH_VARARGS|METH_KEYWORDS, zlib_compress__doc__}, static PyObject * -zlib_compress_impl(PyObject *module, Py_buffer *bytes, int level); +zlib_compress_impl(PyObject *module, Py_buffer *data, int level); static PyObject * -zlib_compress(PyObject *module, PyObject *args) +zlib_compress(PyObject *module, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; - Py_buffer bytes = {NULL, NULL}; + static char *_keywords[] = {"", "level", NULL}; + Py_buffer data = {NULL, NULL}; int level = Z_DEFAULT_COMPRESSION; - if (!PyArg_ParseTuple(args, "y*|i:compress", - &bytes, &level)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "y*|i:compress", _keywords, + &data, &level)) { goto exit; - return_value = zlib_compress_impl(module, &bytes, level); + } + return_value = zlib_compress_impl(module, &data, level); exit: - /* Cleanup for bytes */ - if (bytes.obj) - PyBuffer_Release(&bytes); + /* Cleanup for data */ + if (data.obj) { + PyBuffer_Release(&data); + } return return_value; } @@ -68,14 +71,16 @@ zlib_decompress(PyObject *module, PyObject *args) unsigned int bufsize = DEF_BUF_SIZE; if (!PyArg_ParseTuple(args, "y*|iO&:decompress", - &data, &wbits, capped_uint_converter, &bufsize)) + &data, &wbits, capped_uint_converter, &bufsize)) { goto exit; + } return_value = zlib_decompress_impl(module, &data, wbits, bufsize); exit: /* Cleanup for data */ - if (data.obj) + if (data.obj) { PyBuffer_Release(&data); + } return return_value; } @@ -130,14 +135,16 @@ zlib_compressobj(PyObject *module, PyObject *args, PyObject *kwargs) Py_buffer zdict = {NULL, NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|iiiiiy*:compressobj", _keywords, - &level, &method, &wbits, &memLevel, &strategy, &zdict)) + &level, &method, &wbits, &memLevel, &strategy, &zdict)) { goto exit; + } return_value = zlib_compressobj_impl(module, level, method, wbits, memLevel, strategy, &zdict); exit: /* Cleanup for zdict */ - if (zdict.obj) + if (zdict.obj) { PyBuffer_Release(&zdict); + } return return_value; } @@ -169,8 +176,9 @@ zlib_decompressobj(PyObject *module, PyObject *args, PyObject *kwargs) PyObject *zdict = NULL; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|iO:decompressobj", _keywords, - &wbits, &zdict)) + &wbits, &zdict)) { goto exit; + } return_value = zlib_decompressobj_impl(module, wbits, zdict); exit: @@ -202,14 +210,16 @@ zlib_Compress_compress(compobject *self, PyObject *arg) PyObject *return_value = NULL; Py_buffer data = {NULL, NULL}; - if (!PyArg_Parse(arg, "y*:compress", &data)) + if (!PyArg_Parse(arg, "y*:compress", &data)) { goto exit; + } return_value = zlib_Compress_compress_impl(self, &data); exit: /* Cleanup for data */ - if (data.obj) + if (data.obj) { PyBuffer_Release(&data); + } return return_value; } @@ -246,14 +256,16 @@ zlib_Decompress_decompress(compobject *self, PyObject *args) unsigned int max_length = 0; if (!PyArg_ParseTuple(args, "y*|O&:decompress", - &data, capped_uint_converter, &max_length)) + &data, capped_uint_converter, &max_length)) { goto exit; + } return_value = zlib_Decompress_decompress_impl(self, &data, max_length); exit: /* Cleanup for data */ - if (data.obj) + if (data.obj) { PyBuffer_Release(&data); + } return return_value; } @@ -283,8 +295,9 @@ zlib_Compress_flush(compobject *self, PyObject *args) int mode = Z_FINISH; if (!PyArg_ParseTuple(args, "|i:flush", - &mode)) + &mode)) { goto exit; + } return_value = zlib_Compress_flush_impl(self, mode); exit: @@ -357,8 +370,9 @@ zlib_Decompress_flush(compobject *self, PyObject *args) unsigned int length = DEF_BUF_SIZE; if (!PyArg_ParseTuple(args, "|O&:flush", - capped_uint_converter, &length)) + capped_uint_converter, &length)) { goto exit; + } return_value = zlib_Decompress_flush_impl(self, length); exit: @@ -390,14 +404,16 @@ zlib_adler32(PyObject *module, PyObject *args) unsigned int value = 1; if (!PyArg_ParseTuple(args, "y*|I:adler32", - &data, &value)) + &data, &value)) { goto exit; + } return_value = zlib_adler32_impl(module, &data, value); exit: /* Cleanup for data */ - if (data.obj) + if (data.obj) { PyBuffer_Release(&data); + } return return_value; } @@ -427,14 +443,16 @@ zlib_crc32(PyObject *module, PyObject *args) unsigned int value = 0; if (!PyArg_ParseTuple(args, "y*|I:crc32", - &data, &value)) + &data, &value)) { goto exit; + } return_value = zlib_crc32_impl(module, &data, value); exit: /* Cleanup for data */ - if (data.obj) + if (data.obj) { PyBuffer_Release(&data); + } return return_value; } @@ -442,4 +460,4 @@ exit: #ifndef ZLIB_COMPRESS_COPY_METHODDEF #define ZLIB_COMPRESS_COPY_METHODDEF #endif /* !defined(ZLIB_COMPRESS_COPY_METHODDEF) */ -/*[clinic end generated code: output=8545565b1a1822de input=a9049054013a1b77]*/ +/*[clinic end generated code: output=519446af912f4e72 input=a9049054013a1b77]*/ |