LCOV - code coverage report
Current view: top level - Modules/clinic - zlibmodule.c.h (source / functions) Hit Total Coverage
Test: CPython 3.12 LCOV report [commit 5e6661bce9] Lines: 0 337 0.0 %
Date: 2023-03-20 08:15:36 Functions: 0 17 0.0 %
Branches: 0 318 0.0 %

           Branch data     Line data    Source code
       1                 :            : /*[clinic input]
       2                 :            : preserve
       3                 :            : [clinic start generated code]*/
       4                 :            : 
       5                 :            : #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
       6                 :            : #  include "pycore_gc.h"            // PyGC_Head
       7                 :            : #  include "pycore_runtime.h"       // _Py_ID()
       8                 :            : #endif
       9                 :            : 
      10                 :            : 
      11                 :            : PyDoc_STRVAR(zlib_compress__doc__,
      12                 :            : "compress($module, data, /, level=Z_DEFAULT_COMPRESSION, wbits=MAX_WBITS)\n"
      13                 :            : "--\n"
      14                 :            : "\n"
      15                 :            : "Returns a bytes object containing compressed data.\n"
      16                 :            : "\n"
      17                 :            : "  data\n"
      18                 :            : "    Binary data to be compressed.\n"
      19                 :            : "  level\n"
      20                 :            : "    Compression level, in 0-9 or -1.\n"
      21                 :            : "  wbits\n"
      22                 :            : "    The window buffer size and container format.");
      23                 :            : 
      24                 :            : #define ZLIB_COMPRESS_METHODDEF    \
      25                 :            :     {"compress", _PyCFunction_CAST(zlib_compress), METH_FASTCALL|METH_KEYWORDS, zlib_compress__doc__},
      26                 :            : 
      27                 :            : static PyObject *
      28                 :            : zlib_compress_impl(PyObject *module, Py_buffer *data, int level, int wbits);
      29                 :            : 
      30                 :            : static PyObject *
      31                 :          0 : zlib_compress(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
      32                 :            : {
      33                 :          0 :     PyObject *return_value = NULL;
      34                 :            :     #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
      35                 :            : 
      36                 :            :     #define NUM_KEYWORDS 2
      37                 :            :     static struct {
      38                 :            :         PyGC_Head _this_is_not_used;
      39                 :            :         PyObject_VAR_HEAD
      40                 :            :         PyObject *ob_item[NUM_KEYWORDS];
      41                 :            :     } _kwtuple = {
      42                 :            :         .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
      43                 :            :         .ob_item = { &_Py_ID(level), &_Py_ID(wbits), },
      44                 :            :     };
      45                 :            :     #undef NUM_KEYWORDS
      46                 :            :     #define KWTUPLE (&_kwtuple.ob_base.ob_base)
      47                 :            : 
      48                 :            :     #else  // !Py_BUILD_CORE
      49                 :            :     #  define KWTUPLE NULL
      50                 :            :     #endif  // !Py_BUILD_CORE
      51                 :            : 
      52                 :            :     static const char * const _keywords[] = {"", "level", "wbits", NULL};
      53                 :            :     static _PyArg_Parser _parser = {
      54                 :            :         .keywords = _keywords,
      55                 :            :         .fname = "compress",
      56                 :            :         .kwtuple = KWTUPLE,
      57                 :            :     };
      58                 :            :     #undef KWTUPLE
      59                 :            :     PyObject *argsbuf[3];
      60         [ #  # ]:          0 :     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
      61                 :          0 :     Py_buffer data = {NULL, NULL};
      62                 :          0 :     int level = Z_DEFAULT_COMPRESSION;
      63                 :          0 :     int wbits = MAX_WBITS;
      64                 :            : 
      65   [ #  #  #  #  :          0 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf);
             #  #  #  # ]
      66         [ #  # ]:          0 :     if (!args) {
      67                 :          0 :         goto exit;
      68                 :            :     }
      69         [ #  # ]:          0 :     if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
      70                 :          0 :         goto exit;
      71                 :            :     }
      72         [ #  # ]:          0 :     if (!PyBuffer_IsContiguous(&data, 'C')) {
      73                 :          0 :         _PyArg_BadArgument("compress", "argument 1", "contiguous buffer", args[0]);
      74                 :          0 :         goto exit;
      75                 :            :     }
      76         [ #  # ]:          0 :     if (!noptargs) {
      77                 :          0 :         goto skip_optional_pos;
      78                 :            :     }
      79         [ #  # ]:          0 :     if (args[1]) {
      80                 :          0 :         level = _PyLong_AsInt(args[1]);
      81   [ #  #  #  # ]:          0 :         if (level == -1 && PyErr_Occurred()) {
      82                 :          0 :             goto exit;
      83                 :            :         }
      84         [ #  # ]:          0 :         if (!--noptargs) {
      85                 :          0 :             goto skip_optional_pos;
      86                 :            :         }
      87                 :            :     }
      88                 :          0 :     wbits = _PyLong_AsInt(args[2]);
      89   [ #  #  #  # ]:          0 :     if (wbits == -1 && PyErr_Occurred()) {
      90                 :          0 :         goto exit;
      91                 :            :     }
      92                 :          0 : skip_optional_pos:
      93                 :          0 :     return_value = zlib_compress_impl(module, &data, level, wbits);
      94                 :            : 
      95                 :          0 : exit:
      96                 :            :     /* Cleanup for data */
      97         [ #  # ]:          0 :     if (data.obj) {
      98                 :          0 :        PyBuffer_Release(&data);
      99                 :            :     }
     100                 :            : 
     101                 :          0 :     return return_value;
     102                 :            : }
     103                 :            : 
     104                 :            : PyDoc_STRVAR(zlib_decompress__doc__,
     105                 :            : "decompress($module, data, /, wbits=MAX_WBITS, bufsize=DEF_BUF_SIZE)\n"
     106                 :            : "--\n"
     107                 :            : "\n"
     108                 :            : "Returns a bytes object containing the uncompressed data.\n"
     109                 :            : "\n"
     110                 :            : "  data\n"
     111                 :            : "    Compressed data.\n"
     112                 :            : "  wbits\n"
     113                 :            : "    The window buffer size and container format.\n"
     114                 :            : "  bufsize\n"
     115                 :            : "    The initial output buffer size.");
     116                 :            : 
     117                 :            : #define ZLIB_DECOMPRESS_METHODDEF    \
     118                 :            :     {"decompress", _PyCFunction_CAST(zlib_decompress), METH_FASTCALL|METH_KEYWORDS, zlib_decompress__doc__},
     119                 :            : 
     120                 :            : static PyObject *
     121                 :            : zlib_decompress_impl(PyObject *module, Py_buffer *data, int wbits,
     122                 :            :                      Py_ssize_t bufsize);
     123                 :            : 
     124                 :            : static PyObject *
     125                 :          0 : zlib_decompress(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     126                 :            : {
     127                 :          0 :     PyObject *return_value = NULL;
     128                 :            :     #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
     129                 :            : 
     130                 :            :     #define NUM_KEYWORDS 2
     131                 :            :     static struct {
     132                 :            :         PyGC_Head _this_is_not_used;
     133                 :            :         PyObject_VAR_HEAD
     134                 :            :         PyObject *ob_item[NUM_KEYWORDS];
     135                 :            :     } _kwtuple = {
     136                 :            :         .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
     137                 :            :         .ob_item = { &_Py_ID(wbits), &_Py_ID(bufsize), },
     138                 :            :     };
     139                 :            :     #undef NUM_KEYWORDS
     140                 :            :     #define KWTUPLE (&_kwtuple.ob_base.ob_base)
     141                 :            : 
     142                 :            :     #else  // !Py_BUILD_CORE
     143                 :            :     #  define KWTUPLE NULL
     144                 :            :     #endif  // !Py_BUILD_CORE
     145                 :            : 
     146                 :            :     static const char * const _keywords[] = {"", "wbits", "bufsize", NULL};
     147                 :            :     static _PyArg_Parser _parser = {
     148                 :            :         .keywords = _keywords,
     149                 :            :         .fname = "decompress",
     150                 :            :         .kwtuple = KWTUPLE,
     151                 :            :     };
     152                 :            :     #undef KWTUPLE
     153                 :            :     PyObject *argsbuf[3];
     154         [ #  # ]:          0 :     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
     155                 :          0 :     Py_buffer data = {NULL, NULL};
     156                 :          0 :     int wbits = MAX_WBITS;
     157                 :          0 :     Py_ssize_t bufsize = DEF_BUF_SIZE;
     158                 :            : 
     159   [ #  #  #  #  :          0 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf);
             #  #  #  # ]
     160         [ #  # ]:          0 :     if (!args) {
     161                 :          0 :         goto exit;
     162                 :            :     }
     163         [ #  # ]:          0 :     if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
     164                 :          0 :         goto exit;
     165                 :            :     }
     166         [ #  # ]:          0 :     if (!PyBuffer_IsContiguous(&data, 'C')) {
     167                 :          0 :         _PyArg_BadArgument("decompress", "argument 1", "contiguous buffer", args[0]);
     168                 :          0 :         goto exit;
     169                 :            :     }
     170         [ #  # ]:          0 :     if (!noptargs) {
     171                 :          0 :         goto skip_optional_pos;
     172                 :            :     }
     173         [ #  # ]:          0 :     if (args[1]) {
     174                 :          0 :         wbits = _PyLong_AsInt(args[1]);
     175   [ #  #  #  # ]:          0 :         if (wbits == -1 && PyErr_Occurred()) {
     176                 :          0 :             goto exit;
     177                 :            :         }
     178         [ #  # ]:          0 :         if (!--noptargs) {
     179                 :          0 :             goto skip_optional_pos;
     180                 :            :         }
     181                 :            :     }
     182                 :            :     {
     183                 :          0 :         Py_ssize_t ival = -1;
     184                 :          0 :         PyObject *iobj = _PyNumber_Index(args[2]);
     185         [ #  # ]:          0 :         if (iobj != NULL) {
     186                 :          0 :             ival = PyLong_AsSsize_t(iobj);
     187                 :          0 :             Py_DECREF(iobj);
     188                 :            :         }
     189   [ #  #  #  # ]:          0 :         if (ival == -1 && PyErr_Occurred()) {
     190                 :          0 :             goto exit;
     191                 :            :         }
     192                 :          0 :         bufsize = ival;
     193                 :            :     }
     194                 :          0 : skip_optional_pos:
     195                 :          0 :     return_value = zlib_decompress_impl(module, &data, wbits, bufsize);
     196                 :            : 
     197                 :          0 : exit:
     198                 :            :     /* Cleanup for data */
     199         [ #  # ]:          0 :     if (data.obj) {
     200                 :          0 :        PyBuffer_Release(&data);
     201                 :            :     }
     202                 :            : 
     203                 :          0 :     return return_value;
     204                 :            : }
     205                 :            : 
     206                 :            : PyDoc_STRVAR(zlib_compressobj__doc__,
     207                 :            : "compressobj($module, /, level=Z_DEFAULT_COMPRESSION, method=DEFLATED,\n"
     208                 :            : "            wbits=MAX_WBITS, memLevel=DEF_MEM_LEVEL,\n"
     209                 :            : "            strategy=Z_DEFAULT_STRATEGY, zdict=None)\n"
     210                 :            : "--\n"
     211                 :            : "\n"
     212                 :            : "Return a compressor object.\n"
     213                 :            : "\n"
     214                 :            : "  level\n"
     215                 :            : "    The compression level (an integer in the range 0-9 or -1; default is\n"
     216                 :            : "    currently equivalent to 6).  Higher compression levels are slower,\n"
     217                 :            : "    but produce smaller results.\n"
     218                 :            : "  method\n"
     219                 :            : "    The compression algorithm.  If given, this must be DEFLATED.\n"
     220                 :            : "  wbits\n"
     221                 :            : "    +9 to +15: The base-two logarithm of the window size.  Include a zlib\n"
     222                 :            : "        container.\n"
     223                 :            : "    -9 to -15: Generate a raw stream.\n"
     224                 :            : "    +25 to +31: Include a gzip container.\n"
     225                 :            : "  memLevel\n"
     226                 :            : "    Controls the amount of memory used for internal compression state.\n"
     227                 :            : "    Valid values range from 1 to 9.  Higher values result in higher memory\n"
     228                 :            : "    usage, faster compression, and smaller output.\n"
     229                 :            : "  strategy\n"
     230                 :            : "    Used to tune the compression algorithm.  Possible values are\n"
     231                 :            : "    Z_DEFAULT_STRATEGY, Z_FILTERED, and Z_HUFFMAN_ONLY.\n"
     232                 :            : "  zdict\n"
     233                 :            : "    The predefined compression dictionary - a sequence of bytes\n"
     234                 :            : "    containing subsequences that are likely to occur in the input data.");
     235                 :            : 
     236                 :            : #define ZLIB_COMPRESSOBJ_METHODDEF    \
     237                 :            :     {"compressobj", _PyCFunction_CAST(zlib_compressobj), METH_FASTCALL|METH_KEYWORDS, zlib_compressobj__doc__},
     238                 :            : 
     239                 :            : static PyObject *
     240                 :            : zlib_compressobj_impl(PyObject *module, int level, int method, int wbits,
     241                 :            :                       int memLevel, int strategy, Py_buffer *zdict);
     242                 :            : 
     243                 :            : static PyObject *
     244                 :          0 : zlib_compressobj(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     245                 :            : {
     246                 :          0 :     PyObject *return_value = NULL;
     247                 :            :     #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
     248                 :            : 
     249                 :            :     #define NUM_KEYWORDS 6
     250                 :            :     static struct {
     251                 :            :         PyGC_Head _this_is_not_used;
     252                 :            :         PyObject_VAR_HEAD
     253                 :            :         PyObject *ob_item[NUM_KEYWORDS];
     254                 :            :     } _kwtuple = {
     255                 :            :         .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
     256                 :            :         .ob_item = { &_Py_ID(level), &_Py_ID(method), &_Py_ID(wbits), &_Py_ID(memLevel), &_Py_ID(strategy), &_Py_ID(zdict), },
     257                 :            :     };
     258                 :            :     #undef NUM_KEYWORDS
     259                 :            :     #define KWTUPLE (&_kwtuple.ob_base.ob_base)
     260                 :            : 
     261                 :            :     #else  // !Py_BUILD_CORE
     262                 :            :     #  define KWTUPLE NULL
     263                 :            :     #endif  // !Py_BUILD_CORE
     264                 :            : 
     265                 :            :     static const char * const _keywords[] = {"level", "method", "wbits", "memLevel", "strategy", "zdict", NULL};
     266                 :            :     static _PyArg_Parser _parser = {
     267                 :            :         .keywords = _keywords,
     268                 :            :         .fname = "compressobj",
     269                 :            :         .kwtuple = KWTUPLE,
     270                 :            :     };
     271                 :            :     #undef KWTUPLE
     272                 :            :     PyObject *argsbuf[6];
     273         [ #  # ]:          0 :     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
     274                 :          0 :     int level = Z_DEFAULT_COMPRESSION;
     275                 :          0 :     int method = DEFLATED;
     276                 :          0 :     int wbits = MAX_WBITS;
     277                 :          0 :     int memLevel = DEF_MEM_LEVEL;
     278                 :          0 :     int strategy = Z_DEFAULT_STRATEGY;
     279                 :          0 :     Py_buffer zdict = {NULL, NULL};
     280                 :            : 
     281   [ #  #  #  #  :          0 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 6, 0, argsbuf);
             #  #  #  # ]
     282         [ #  # ]:          0 :     if (!args) {
     283                 :          0 :         goto exit;
     284                 :            :     }
     285         [ #  # ]:          0 :     if (!noptargs) {
     286                 :          0 :         goto skip_optional_pos;
     287                 :            :     }
     288         [ #  # ]:          0 :     if (args[0]) {
     289                 :          0 :         level = _PyLong_AsInt(args[0]);
     290   [ #  #  #  # ]:          0 :         if (level == -1 && PyErr_Occurred()) {
     291                 :          0 :             goto exit;
     292                 :            :         }
     293         [ #  # ]:          0 :         if (!--noptargs) {
     294                 :          0 :             goto skip_optional_pos;
     295                 :            :         }
     296                 :            :     }
     297         [ #  # ]:          0 :     if (args[1]) {
     298                 :          0 :         method = _PyLong_AsInt(args[1]);
     299   [ #  #  #  # ]:          0 :         if (method == -1 && PyErr_Occurred()) {
     300                 :          0 :             goto exit;
     301                 :            :         }
     302         [ #  # ]:          0 :         if (!--noptargs) {
     303                 :          0 :             goto skip_optional_pos;
     304                 :            :         }
     305                 :            :     }
     306         [ #  # ]:          0 :     if (args[2]) {
     307                 :          0 :         wbits = _PyLong_AsInt(args[2]);
     308   [ #  #  #  # ]:          0 :         if (wbits == -1 && PyErr_Occurred()) {
     309                 :          0 :             goto exit;
     310                 :            :         }
     311         [ #  # ]:          0 :         if (!--noptargs) {
     312                 :          0 :             goto skip_optional_pos;
     313                 :            :         }
     314                 :            :     }
     315         [ #  # ]:          0 :     if (args[3]) {
     316                 :          0 :         memLevel = _PyLong_AsInt(args[3]);
     317   [ #  #  #  # ]:          0 :         if (memLevel == -1 && PyErr_Occurred()) {
     318                 :          0 :             goto exit;
     319                 :            :         }
     320         [ #  # ]:          0 :         if (!--noptargs) {
     321                 :          0 :             goto skip_optional_pos;
     322                 :            :         }
     323                 :            :     }
     324         [ #  # ]:          0 :     if (args[4]) {
     325                 :          0 :         strategy = _PyLong_AsInt(args[4]);
     326   [ #  #  #  # ]:          0 :         if (strategy == -1 && PyErr_Occurred()) {
     327                 :          0 :             goto exit;
     328                 :            :         }
     329         [ #  # ]:          0 :         if (!--noptargs) {
     330                 :          0 :             goto skip_optional_pos;
     331                 :            :         }
     332                 :            :     }
     333         [ #  # ]:          0 :     if (PyObject_GetBuffer(args[5], &zdict, PyBUF_SIMPLE) != 0) {
     334                 :          0 :         goto exit;
     335                 :            :     }
     336         [ #  # ]:          0 :     if (!PyBuffer_IsContiguous(&zdict, 'C')) {
     337                 :          0 :         _PyArg_BadArgument("compressobj", "argument 'zdict'", "contiguous buffer", args[5]);
     338                 :          0 :         goto exit;
     339                 :            :     }
     340                 :          0 : skip_optional_pos:
     341                 :          0 :     return_value = zlib_compressobj_impl(module, level, method, wbits, memLevel, strategy, &zdict);
     342                 :            : 
     343                 :          0 : exit:
     344                 :            :     /* Cleanup for zdict */
     345         [ #  # ]:          0 :     if (zdict.obj) {
     346                 :          0 :        PyBuffer_Release(&zdict);
     347                 :            :     }
     348                 :            : 
     349                 :          0 :     return return_value;
     350                 :            : }
     351                 :            : 
     352                 :            : PyDoc_STRVAR(zlib_decompressobj__doc__,
     353                 :            : "decompressobj($module, /, wbits=MAX_WBITS, zdict=b\'\')\n"
     354                 :            : "--\n"
     355                 :            : "\n"
     356                 :            : "Return a decompressor object.\n"
     357                 :            : "\n"
     358                 :            : "  wbits\n"
     359                 :            : "    The window buffer size and container format.\n"
     360                 :            : "  zdict\n"
     361                 :            : "    The predefined compression dictionary.  This must be the same\n"
     362                 :            : "    dictionary as used by the compressor that produced the input data.");
     363                 :            : 
     364                 :            : #define ZLIB_DECOMPRESSOBJ_METHODDEF    \
     365                 :            :     {"decompressobj", _PyCFunction_CAST(zlib_decompressobj), METH_FASTCALL|METH_KEYWORDS, zlib_decompressobj__doc__},
     366                 :            : 
     367                 :            : static PyObject *
     368                 :            : zlib_decompressobj_impl(PyObject *module, int wbits, PyObject *zdict);
     369                 :            : 
     370                 :            : static PyObject *
     371                 :          0 : zlib_decompressobj(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     372                 :            : {
     373                 :          0 :     PyObject *return_value = NULL;
     374                 :            :     #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
     375                 :            : 
     376                 :            :     #define NUM_KEYWORDS 2
     377                 :            :     static struct {
     378                 :            :         PyGC_Head _this_is_not_used;
     379                 :            :         PyObject_VAR_HEAD
     380                 :            :         PyObject *ob_item[NUM_KEYWORDS];
     381                 :            :     } _kwtuple = {
     382                 :            :         .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
     383                 :            :         .ob_item = { &_Py_ID(wbits), &_Py_ID(zdict), },
     384                 :            :     };
     385                 :            :     #undef NUM_KEYWORDS
     386                 :            :     #define KWTUPLE (&_kwtuple.ob_base.ob_base)
     387                 :            : 
     388                 :            :     #else  // !Py_BUILD_CORE
     389                 :            :     #  define KWTUPLE NULL
     390                 :            :     #endif  // !Py_BUILD_CORE
     391                 :            : 
     392                 :            :     static const char * const _keywords[] = {"wbits", "zdict", NULL};
     393                 :            :     static _PyArg_Parser _parser = {
     394                 :            :         .keywords = _keywords,
     395                 :            :         .fname = "decompressobj",
     396                 :            :         .kwtuple = KWTUPLE,
     397                 :            :     };
     398                 :            :     #undef KWTUPLE
     399                 :            :     PyObject *argsbuf[2];
     400         [ #  # ]:          0 :     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
     401                 :          0 :     int wbits = MAX_WBITS;
     402                 :          0 :     PyObject *zdict = NULL;
     403                 :            : 
     404   [ #  #  #  #  :          0 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 2, 0, argsbuf);
             #  #  #  # ]
     405         [ #  # ]:          0 :     if (!args) {
     406                 :          0 :         goto exit;
     407                 :            :     }
     408         [ #  # ]:          0 :     if (!noptargs) {
     409                 :          0 :         goto skip_optional_pos;
     410                 :            :     }
     411         [ #  # ]:          0 :     if (args[0]) {
     412                 :          0 :         wbits = _PyLong_AsInt(args[0]);
     413   [ #  #  #  # ]:          0 :         if (wbits == -1 && PyErr_Occurred()) {
     414                 :          0 :             goto exit;
     415                 :            :         }
     416         [ #  # ]:          0 :         if (!--noptargs) {
     417                 :          0 :             goto skip_optional_pos;
     418                 :            :         }
     419                 :            :     }
     420                 :          0 :     zdict = args[1];
     421                 :          0 : skip_optional_pos:
     422                 :          0 :     return_value = zlib_decompressobj_impl(module, wbits, zdict);
     423                 :            : 
     424                 :          0 : exit:
     425                 :          0 :     return return_value;
     426                 :            : }
     427                 :            : 
     428                 :            : PyDoc_STRVAR(zlib_Compress_compress__doc__,
     429                 :            : "compress($self, data, /)\n"
     430                 :            : "--\n"
     431                 :            : "\n"
     432                 :            : "Returns a bytes object containing compressed data.\n"
     433                 :            : "\n"
     434                 :            : "  data\n"
     435                 :            : "    Binary data to be compressed.\n"
     436                 :            : "\n"
     437                 :            : "After calling this function, some of the input data may still\n"
     438                 :            : "be stored in internal buffers for later processing.\n"
     439                 :            : "Call the flush() method to clear these buffers.");
     440                 :            : 
     441                 :            : #define ZLIB_COMPRESS_COMPRESS_METHODDEF    \
     442                 :            :     {"compress", _PyCFunction_CAST(zlib_Compress_compress), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, zlib_Compress_compress__doc__},
     443                 :            : 
     444                 :            : static PyObject *
     445                 :            : zlib_Compress_compress_impl(compobject *self, PyTypeObject *cls,
     446                 :            :                             Py_buffer *data);
     447                 :            : 
     448                 :            : static PyObject *
     449                 :          0 : zlib_Compress_compress(compobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     450                 :            : {
     451                 :          0 :     PyObject *return_value = NULL;
     452                 :            :     #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
     453                 :            :     #  define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
     454                 :            :     #else
     455                 :            :     #  define KWTUPLE NULL
     456                 :            :     #endif
     457                 :            : 
     458                 :            :     static const char * const _keywords[] = {"", NULL};
     459                 :            :     static _PyArg_Parser _parser = {
     460                 :            :         .keywords = _keywords,
     461                 :            :         .fname = "compress",
     462                 :            :         .kwtuple = KWTUPLE,
     463                 :            :     };
     464                 :            :     #undef KWTUPLE
     465                 :            :     PyObject *argsbuf[1];
     466                 :          0 :     Py_buffer data = {NULL, NULL};
     467                 :            : 
     468   [ #  #  #  #  :          0 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
             #  #  #  # ]
     469         [ #  # ]:          0 :     if (!args) {
     470                 :          0 :         goto exit;
     471                 :            :     }
     472         [ #  # ]:          0 :     if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
     473                 :          0 :         goto exit;
     474                 :            :     }
     475         [ #  # ]:          0 :     if (!PyBuffer_IsContiguous(&data, 'C')) {
     476                 :          0 :         _PyArg_BadArgument("compress", "argument 1", "contiguous buffer", args[0]);
     477                 :          0 :         goto exit;
     478                 :            :     }
     479                 :          0 :     return_value = zlib_Compress_compress_impl(self, cls, &data);
     480                 :            : 
     481                 :          0 : exit:
     482                 :            :     /* Cleanup for data */
     483         [ #  # ]:          0 :     if (data.obj) {
     484                 :          0 :        PyBuffer_Release(&data);
     485                 :            :     }
     486                 :            : 
     487                 :          0 :     return return_value;
     488                 :            : }
     489                 :            : 
     490                 :            : PyDoc_STRVAR(zlib_Decompress_decompress__doc__,
     491                 :            : "decompress($self, data, /, max_length=0)\n"
     492                 :            : "--\n"
     493                 :            : "\n"
     494                 :            : "Return a bytes object containing the decompressed version of the data.\n"
     495                 :            : "\n"
     496                 :            : "  data\n"
     497                 :            : "    The binary data to decompress.\n"
     498                 :            : "  max_length\n"
     499                 :            : "    The maximum allowable length of the decompressed data.\n"
     500                 :            : "    Unconsumed input data will be stored in\n"
     501                 :            : "    the unconsumed_tail attribute.\n"
     502                 :            : "\n"
     503                 :            : "After calling this function, some of the input data may still be stored in\n"
     504                 :            : "internal buffers for later processing.\n"
     505                 :            : "Call the flush() method to clear these buffers.");
     506                 :            : 
     507                 :            : #define ZLIB_DECOMPRESS_DECOMPRESS_METHODDEF    \
     508                 :            :     {"decompress", _PyCFunction_CAST(zlib_Decompress_decompress), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, zlib_Decompress_decompress__doc__},
     509                 :            : 
     510                 :            : static PyObject *
     511                 :            : zlib_Decompress_decompress_impl(compobject *self, PyTypeObject *cls,
     512                 :            :                                 Py_buffer *data, Py_ssize_t max_length);
     513                 :            : 
     514                 :            : static PyObject *
     515                 :          0 : zlib_Decompress_decompress(compobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     516                 :            : {
     517                 :          0 :     PyObject *return_value = NULL;
     518                 :            :     #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
     519                 :            : 
     520                 :            :     #define NUM_KEYWORDS 1
     521                 :            :     static struct {
     522                 :            :         PyGC_Head _this_is_not_used;
     523                 :            :         PyObject_VAR_HEAD
     524                 :            :         PyObject *ob_item[NUM_KEYWORDS];
     525                 :            :     } _kwtuple = {
     526                 :            :         .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
     527                 :            :         .ob_item = { &_Py_ID(max_length), },
     528                 :            :     };
     529                 :            :     #undef NUM_KEYWORDS
     530                 :            :     #define KWTUPLE (&_kwtuple.ob_base.ob_base)
     531                 :            : 
     532                 :            :     #else  // !Py_BUILD_CORE
     533                 :            :     #  define KWTUPLE NULL
     534                 :            :     #endif  // !Py_BUILD_CORE
     535                 :            : 
     536                 :            :     static const char * const _keywords[] = {"", "max_length", NULL};
     537                 :            :     static _PyArg_Parser _parser = {
     538                 :            :         .keywords = _keywords,
     539                 :            :         .fname = "decompress",
     540                 :            :         .kwtuple = KWTUPLE,
     541                 :            :     };
     542                 :            :     #undef KWTUPLE
     543                 :            :     PyObject *argsbuf[2];
     544         [ #  # ]:          0 :     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
     545                 :          0 :     Py_buffer data = {NULL, NULL};
     546                 :          0 :     Py_ssize_t max_length = 0;
     547                 :            : 
     548   [ #  #  #  #  :          0 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
             #  #  #  # ]
     549         [ #  # ]:          0 :     if (!args) {
     550                 :          0 :         goto exit;
     551                 :            :     }
     552         [ #  # ]:          0 :     if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
     553                 :          0 :         goto exit;
     554                 :            :     }
     555         [ #  # ]:          0 :     if (!PyBuffer_IsContiguous(&data, 'C')) {
     556                 :          0 :         _PyArg_BadArgument("decompress", "argument 1", "contiguous buffer", args[0]);
     557                 :          0 :         goto exit;
     558                 :            :     }
     559         [ #  # ]:          0 :     if (!noptargs) {
     560                 :          0 :         goto skip_optional_pos;
     561                 :            :     }
     562                 :            :     {
     563                 :          0 :         Py_ssize_t ival = -1;
     564                 :          0 :         PyObject *iobj = _PyNumber_Index(args[1]);
     565         [ #  # ]:          0 :         if (iobj != NULL) {
     566                 :          0 :             ival = PyLong_AsSsize_t(iobj);
     567                 :          0 :             Py_DECREF(iobj);
     568                 :            :         }
     569   [ #  #  #  # ]:          0 :         if (ival == -1 && PyErr_Occurred()) {
     570                 :          0 :             goto exit;
     571                 :            :         }
     572                 :          0 :         max_length = ival;
     573                 :            :     }
     574                 :          0 : skip_optional_pos:
     575                 :          0 :     return_value = zlib_Decompress_decompress_impl(self, cls, &data, max_length);
     576                 :            : 
     577                 :          0 : exit:
     578                 :            :     /* Cleanup for data */
     579         [ #  # ]:          0 :     if (data.obj) {
     580                 :          0 :        PyBuffer_Release(&data);
     581                 :            :     }
     582                 :            : 
     583                 :          0 :     return return_value;
     584                 :            : }
     585                 :            : 
     586                 :            : PyDoc_STRVAR(zlib_Compress_flush__doc__,
     587                 :            : "flush($self, mode=zlib.Z_FINISH, /)\n"
     588                 :            : "--\n"
     589                 :            : "\n"
     590                 :            : "Return a bytes object containing any remaining compressed data.\n"
     591                 :            : "\n"
     592                 :            : "  mode\n"
     593                 :            : "    One of the constants Z_SYNC_FLUSH, Z_FULL_FLUSH, Z_FINISH.\n"
     594                 :            : "    If mode == Z_FINISH, the compressor object can no longer be\n"
     595                 :            : "    used after calling the flush() method.  Otherwise, more data\n"
     596                 :            : "    can still be compressed.");
     597                 :            : 
     598                 :            : #define ZLIB_COMPRESS_FLUSH_METHODDEF    \
     599                 :            :     {"flush", _PyCFunction_CAST(zlib_Compress_flush), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, zlib_Compress_flush__doc__},
     600                 :            : 
     601                 :            : static PyObject *
     602                 :            : zlib_Compress_flush_impl(compobject *self, PyTypeObject *cls, int mode);
     603                 :            : 
     604                 :            : static PyObject *
     605                 :          0 : zlib_Compress_flush(compobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     606                 :            : {
     607                 :          0 :     PyObject *return_value = NULL;
     608                 :            :     #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
     609                 :            :     #  define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
     610                 :            :     #else
     611                 :            :     #  define KWTUPLE NULL
     612                 :            :     #endif
     613                 :            : 
     614                 :            :     static const char * const _keywords[] = {"", NULL};
     615                 :            :     static _PyArg_Parser _parser = {
     616                 :            :         .keywords = _keywords,
     617                 :            :         .fname = "flush",
     618                 :            :         .kwtuple = KWTUPLE,
     619                 :            :     };
     620                 :            :     #undef KWTUPLE
     621                 :            :     PyObject *argsbuf[1];
     622                 :          0 :     int mode = Z_FINISH;
     623                 :            : 
     624   [ #  #  #  #  :          0 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
             #  #  #  # ]
     625         [ #  # ]:          0 :     if (!args) {
     626                 :          0 :         goto exit;
     627                 :            :     }
     628         [ #  # ]:          0 :     if (nargs < 1) {
     629                 :          0 :         goto skip_optional_posonly;
     630                 :            :     }
     631                 :          0 :     mode = _PyLong_AsInt(args[0]);
     632   [ #  #  #  # ]:          0 :     if (mode == -1 && PyErr_Occurred()) {
     633                 :          0 :         goto exit;
     634                 :            :     }
     635                 :          0 : skip_optional_posonly:
     636                 :          0 :     return_value = zlib_Compress_flush_impl(self, cls, mode);
     637                 :            : 
     638                 :          0 : exit:
     639                 :          0 :     return return_value;
     640                 :            : }
     641                 :            : 
     642                 :            : #if defined(HAVE_ZLIB_COPY)
     643                 :            : 
     644                 :            : PyDoc_STRVAR(zlib_Compress_copy__doc__,
     645                 :            : "copy($self, /)\n"
     646                 :            : "--\n"
     647                 :            : "\n"
     648                 :            : "Return a copy of the compression object.");
     649                 :            : 
     650                 :            : #define ZLIB_COMPRESS_COPY_METHODDEF    \
     651                 :            :     {"copy", _PyCFunction_CAST(zlib_Compress_copy), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, zlib_Compress_copy__doc__},
     652                 :            : 
     653                 :            : static PyObject *
     654                 :            : zlib_Compress_copy_impl(compobject *self, PyTypeObject *cls);
     655                 :            : 
     656                 :            : static PyObject *
     657                 :          0 : zlib_Compress_copy(compobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     658                 :            : {
     659         [ #  # ]:          0 :     if (nargs) {
     660                 :          0 :         PyErr_SetString(PyExc_TypeError, "copy() takes no arguments");
     661                 :          0 :         return NULL;
     662                 :            :     }
     663                 :          0 :     return zlib_Compress_copy_impl(self, cls);
     664                 :            : }
     665                 :            : 
     666                 :            : #endif /* defined(HAVE_ZLIB_COPY) */
     667                 :            : 
     668                 :            : #if defined(HAVE_ZLIB_COPY)
     669                 :            : 
     670                 :            : PyDoc_STRVAR(zlib_Compress___copy____doc__,
     671                 :            : "__copy__($self, /)\n"
     672                 :            : "--\n"
     673                 :            : "\n");
     674                 :            : 
     675                 :            : #define ZLIB_COMPRESS___COPY___METHODDEF    \
     676                 :            :     {"__copy__", _PyCFunction_CAST(zlib_Compress___copy__), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, zlib_Compress___copy____doc__},
     677                 :            : 
     678                 :            : static PyObject *
     679                 :            : zlib_Compress___copy___impl(compobject *self, PyTypeObject *cls);
     680                 :            : 
     681                 :            : static PyObject *
     682                 :          0 : zlib_Compress___copy__(compobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     683                 :            : {
     684         [ #  # ]:          0 :     if (nargs) {
     685                 :          0 :         PyErr_SetString(PyExc_TypeError, "__copy__() takes no arguments");
     686                 :          0 :         return NULL;
     687                 :            :     }
     688                 :          0 :     return zlib_Compress___copy___impl(self, cls);
     689                 :            : }
     690                 :            : 
     691                 :            : #endif /* defined(HAVE_ZLIB_COPY) */
     692                 :            : 
     693                 :            : #if defined(HAVE_ZLIB_COPY)
     694                 :            : 
     695                 :            : PyDoc_STRVAR(zlib_Compress___deepcopy____doc__,
     696                 :            : "__deepcopy__($self, memo, /)\n"
     697                 :            : "--\n"
     698                 :            : "\n");
     699                 :            : 
     700                 :            : #define ZLIB_COMPRESS___DEEPCOPY___METHODDEF    \
     701                 :            :     {"__deepcopy__", _PyCFunction_CAST(zlib_Compress___deepcopy__), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, zlib_Compress___deepcopy____doc__},
     702                 :            : 
     703                 :            : static PyObject *
     704                 :            : zlib_Compress___deepcopy___impl(compobject *self, PyTypeObject *cls,
     705                 :            :                                 PyObject *memo);
     706                 :            : 
     707                 :            : static PyObject *
     708                 :          0 : zlib_Compress___deepcopy__(compobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     709                 :            : {
     710                 :          0 :     PyObject *return_value = NULL;
     711                 :            :     #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
     712                 :            :     #  define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
     713                 :            :     #else
     714                 :            :     #  define KWTUPLE NULL
     715                 :            :     #endif
     716                 :            : 
     717                 :            :     static const char * const _keywords[] = {"", NULL};
     718                 :            :     static _PyArg_Parser _parser = {
     719                 :            :         .keywords = _keywords,
     720                 :            :         .fname = "__deepcopy__",
     721                 :            :         .kwtuple = KWTUPLE,
     722                 :            :     };
     723                 :            :     #undef KWTUPLE
     724                 :            :     PyObject *argsbuf[1];
     725                 :            :     PyObject *memo;
     726                 :            : 
     727   [ #  #  #  #  :          0 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
             #  #  #  # ]
     728         [ #  # ]:          0 :     if (!args) {
     729                 :          0 :         goto exit;
     730                 :            :     }
     731                 :          0 :     memo = args[0];
     732                 :          0 :     return_value = zlib_Compress___deepcopy___impl(self, cls, memo);
     733                 :            : 
     734                 :          0 : exit:
     735                 :          0 :     return return_value;
     736                 :            : }
     737                 :            : 
     738                 :            : #endif /* defined(HAVE_ZLIB_COPY) */
     739                 :            : 
     740                 :            : #if defined(HAVE_ZLIB_COPY)
     741                 :            : 
     742                 :            : PyDoc_STRVAR(zlib_Decompress_copy__doc__,
     743                 :            : "copy($self, /)\n"
     744                 :            : "--\n"
     745                 :            : "\n"
     746                 :            : "Return a copy of the decompression object.");
     747                 :            : 
     748                 :            : #define ZLIB_DECOMPRESS_COPY_METHODDEF    \
     749                 :            :     {"copy", _PyCFunction_CAST(zlib_Decompress_copy), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, zlib_Decompress_copy__doc__},
     750                 :            : 
     751                 :            : static PyObject *
     752                 :            : zlib_Decompress_copy_impl(compobject *self, PyTypeObject *cls);
     753                 :            : 
     754                 :            : static PyObject *
     755                 :          0 : zlib_Decompress_copy(compobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     756                 :            : {
     757         [ #  # ]:          0 :     if (nargs) {
     758                 :          0 :         PyErr_SetString(PyExc_TypeError, "copy() takes no arguments");
     759                 :          0 :         return NULL;
     760                 :            :     }
     761                 :          0 :     return zlib_Decompress_copy_impl(self, cls);
     762                 :            : }
     763                 :            : 
     764                 :            : #endif /* defined(HAVE_ZLIB_COPY) */
     765                 :            : 
     766                 :            : #if defined(HAVE_ZLIB_COPY)
     767                 :            : 
     768                 :            : PyDoc_STRVAR(zlib_Decompress___copy____doc__,
     769                 :            : "__copy__($self, /)\n"
     770                 :            : "--\n"
     771                 :            : "\n");
     772                 :            : 
     773                 :            : #define ZLIB_DECOMPRESS___COPY___METHODDEF    \
     774                 :            :     {"__copy__", _PyCFunction_CAST(zlib_Decompress___copy__), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, zlib_Decompress___copy____doc__},
     775                 :            : 
     776                 :            : static PyObject *
     777                 :            : zlib_Decompress___copy___impl(compobject *self, PyTypeObject *cls);
     778                 :            : 
     779                 :            : static PyObject *
     780                 :          0 : zlib_Decompress___copy__(compobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     781                 :            : {
     782         [ #  # ]:          0 :     if (nargs) {
     783                 :          0 :         PyErr_SetString(PyExc_TypeError, "__copy__() takes no arguments");
     784                 :          0 :         return NULL;
     785                 :            :     }
     786                 :          0 :     return zlib_Decompress___copy___impl(self, cls);
     787                 :            : }
     788                 :            : 
     789                 :            : #endif /* defined(HAVE_ZLIB_COPY) */
     790                 :            : 
     791                 :            : #if defined(HAVE_ZLIB_COPY)
     792                 :            : 
     793                 :            : PyDoc_STRVAR(zlib_Decompress___deepcopy____doc__,
     794                 :            : "__deepcopy__($self, memo, /)\n"
     795                 :            : "--\n"
     796                 :            : "\n");
     797                 :            : 
     798                 :            : #define ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF    \
     799                 :            :     {"__deepcopy__", _PyCFunction_CAST(zlib_Decompress___deepcopy__), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, zlib_Decompress___deepcopy____doc__},
     800                 :            : 
     801                 :            : static PyObject *
     802                 :            : zlib_Decompress___deepcopy___impl(compobject *self, PyTypeObject *cls,
     803                 :            :                                   PyObject *memo);
     804                 :            : 
     805                 :            : static PyObject *
     806                 :          0 : zlib_Decompress___deepcopy__(compobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     807                 :            : {
     808                 :          0 :     PyObject *return_value = NULL;
     809                 :            :     #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
     810                 :            :     #  define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
     811                 :            :     #else
     812                 :            :     #  define KWTUPLE NULL
     813                 :            :     #endif
     814                 :            : 
     815                 :            :     static const char * const _keywords[] = {"", NULL};
     816                 :            :     static _PyArg_Parser _parser = {
     817                 :            :         .keywords = _keywords,
     818                 :            :         .fname = "__deepcopy__",
     819                 :            :         .kwtuple = KWTUPLE,
     820                 :            :     };
     821                 :            :     #undef KWTUPLE
     822                 :            :     PyObject *argsbuf[1];
     823                 :            :     PyObject *memo;
     824                 :            : 
     825   [ #  #  #  #  :          0 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
             #  #  #  # ]
     826         [ #  # ]:          0 :     if (!args) {
     827                 :          0 :         goto exit;
     828                 :            :     }
     829                 :          0 :     memo = args[0];
     830                 :          0 :     return_value = zlib_Decompress___deepcopy___impl(self, cls, memo);
     831                 :            : 
     832                 :          0 : exit:
     833                 :          0 :     return return_value;
     834                 :            : }
     835                 :            : 
     836                 :            : #endif /* defined(HAVE_ZLIB_COPY) */
     837                 :            : 
     838                 :            : PyDoc_STRVAR(zlib_Decompress_flush__doc__,
     839                 :            : "flush($self, length=zlib.DEF_BUF_SIZE, /)\n"
     840                 :            : "--\n"
     841                 :            : "\n"
     842                 :            : "Return a bytes object containing any remaining decompressed data.\n"
     843                 :            : "\n"
     844                 :            : "  length\n"
     845                 :            : "    the initial size of the output buffer.");
     846                 :            : 
     847                 :            : #define ZLIB_DECOMPRESS_FLUSH_METHODDEF    \
     848                 :            :     {"flush", _PyCFunction_CAST(zlib_Decompress_flush), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, zlib_Decompress_flush__doc__},
     849                 :            : 
     850                 :            : static PyObject *
     851                 :            : zlib_Decompress_flush_impl(compobject *self, PyTypeObject *cls,
     852                 :            :                            Py_ssize_t length);
     853                 :            : 
     854                 :            : static PyObject *
     855                 :          0 : zlib_Decompress_flush(compobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     856                 :            : {
     857                 :          0 :     PyObject *return_value = NULL;
     858                 :            :     #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
     859                 :            :     #  define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
     860                 :            :     #else
     861                 :            :     #  define KWTUPLE NULL
     862                 :            :     #endif
     863                 :            : 
     864                 :            :     static const char * const _keywords[] = {"", NULL};
     865                 :            :     static _PyArg_Parser _parser = {
     866                 :            :         .keywords = _keywords,
     867                 :            :         .fname = "flush",
     868                 :            :         .kwtuple = KWTUPLE,
     869                 :            :     };
     870                 :            :     #undef KWTUPLE
     871                 :            :     PyObject *argsbuf[1];
     872                 :          0 :     Py_ssize_t length = DEF_BUF_SIZE;
     873                 :            : 
     874   [ #  #  #  #  :          0 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
             #  #  #  # ]
     875         [ #  # ]:          0 :     if (!args) {
     876                 :          0 :         goto exit;
     877                 :            :     }
     878         [ #  # ]:          0 :     if (nargs < 1) {
     879                 :          0 :         goto skip_optional_posonly;
     880                 :            :     }
     881                 :            :     {
     882                 :          0 :         Py_ssize_t ival = -1;
     883                 :          0 :         PyObject *iobj = _PyNumber_Index(args[0]);
     884         [ #  # ]:          0 :         if (iobj != NULL) {
     885                 :          0 :             ival = PyLong_AsSsize_t(iobj);
     886                 :          0 :             Py_DECREF(iobj);
     887                 :            :         }
     888   [ #  #  #  # ]:          0 :         if (ival == -1 && PyErr_Occurred()) {
     889                 :          0 :             goto exit;
     890                 :            :         }
     891                 :          0 :         length = ival;
     892                 :            :     }
     893                 :          0 : skip_optional_posonly:
     894                 :          0 :     return_value = zlib_Decompress_flush_impl(self, cls, length);
     895                 :            : 
     896                 :          0 : exit:
     897                 :          0 :     return return_value;
     898                 :            : }
     899                 :            : 
     900                 :            : PyDoc_STRVAR(zlib_ZlibDecompressor_decompress__doc__,
     901                 :            : "decompress($self, /, data, max_length=-1)\n"
     902                 :            : "--\n"
     903                 :            : "\n"
     904                 :            : "Decompress *data*, returning uncompressed data as bytes.\n"
     905                 :            : "\n"
     906                 :            : "If *max_length* is nonnegative, returns at most *max_length* bytes of\n"
     907                 :            : "decompressed data. If this limit is reached and further output can be\n"
     908                 :            : "produced, *self.needs_input* will be set to ``False``. In this case, the next\n"
     909                 :            : "call to *decompress()* may provide *data* as b\'\' to obtain more of the output.\n"
     910                 :            : "\n"
     911                 :            : "If all of the input data was decompressed and returned (either because this\n"
     912                 :            : "was less than *max_length* bytes, or because *max_length* was negative),\n"
     913                 :            : "*self.needs_input* will be set to True.\n"
     914                 :            : "\n"
     915                 :            : "Attempting to decompress data after the end of stream is reached raises an\n"
     916                 :            : "EOFError.  Any data found after the end of the stream is ignored and saved in\n"
     917                 :            : "the unused_data attribute.");
     918                 :            : 
     919                 :            : #define ZLIB_ZLIBDECOMPRESSOR_DECOMPRESS_METHODDEF    \
     920                 :            :     {"decompress", _PyCFunction_CAST(zlib_ZlibDecompressor_decompress), METH_FASTCALL|METH_KEYWORDS, zlib_ZlibDecompressor_decompress__doc__},
     921                 :            : 
     922                 :            : static PyObject *
     923                 :            : zlib_ZlibDecompressor_decompress_impl(ZlibDecompressor *self,
     924                 :            :                                       Py_buffer *data, Py_ssize_t max_length);
     925                 :            : 
     926                 :            : static PyObject *
     927                 :          0 : zlib_ZlibDecompressor_decompress(ZlibDecompressor *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     928                 :            : {
     929                 :          0 :     PyObject *return_value = NULL;
     930                 :            :     #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
     931                 :            : 
     932                 :            :     #define NUM_KEYWORDS 2
     933                 :            :     static struct {
     934                 :            :         PyGC_Head _this_is_not_used;
     935                 :            :         PyObject_VAR_HEAD
     936                 :            :         PyObject *ob_item[NUM_KEYWORDS];
     937                 :            :     } _kwtuple = {
     938                 :            :         .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
     939                 :            :         .ob_item = { &_Py_ID(data), &_Py_ID(max_length), },
     940                 :            :     };
     941                 :            :     #undef NUM_KEYWORDS
     942                 :            :     #define KWTUPLE (&_kwtuple.ob_base.ob_base)
     943                 :            : 
     944                 :            :     #else  // !Py_BUILD_CORE
     945                 :            :     #  define KWTUPLE NULL
     946                 :            :     #endif  // !Py_BUILD_CORE
     947                 :            : 
     948                 :            :     static const char * const _keywords[] = {"data", "max_length", NULL};
     949                 :            :     static _PyArg_Parser _parser = {
     950                 :            :         .keywords = _keywords,
     951                 :            :         .fname = "decompress",
     952                 :            :         .kwtuple = KWTUPLE,
     953                 :            :     };
     954                 :            :     #undef KWTUPLE
     955                 :            :     PyObject *argsbuf[2];
     956         [ #  # ]:          0 :     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
     957                 :          0 :     Py_buffer data = {NULL, NULL};
     958                 :          0 :     Py_ssize_t max_length = -1;
     959                 :            : 
     960   [ #  #  #  #  :          0 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
             #  #  #  # ]
     961         [ #  # ]:          0 :     if (!args) {
     962                 :          0 :         goto exit;
     963                 :            :     }
     964         [ #  # ]:          0 :     if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
     965                 :          0 :         goto exit;
     966                 :            :     }
     967         [ #  # ]:          0 :     if (!PyBuffer_IsContiguous(&data, 'C')) {
     968                 :          0 :         _PyArg_BadArgument("decompress", "argument 'data'", "contiguous buffer", args[0]);
     969                 :          0 :         goto exit;
     970                 :            :     }
     971         [ #  # ]:          0 :     if (!noptargs) {
     972                 :          0 :         goto skip_optional_pos;
     973                 :            :     }
     974                 :            :     {
     975                 :          0 :         Py_ssize_t ival = -1;
     976                 :          0 :         PyObject *iobj = _PyNumber_Index(args[1]);
     977         [ #  # ]:          0 :         if (iobj != NULL) {
     978                 :          0 :             ival = PyLong_AsSsize_t(iobj);
     979                 :          0 :             Py_DECREF(iobj);
     980                 :            :         }
     981   [ #  #  #  # ]:          0 :         if (ival == -1 && PyErr_Occurred()) {
     982                 :          0 :             goto exit;
     983                 :            :         }
     984                 :          0 :         max_length = ival;
     985                 :            :     }
     986                 :          0 : skip_optional_pos:
     987                 :          0 :     return_value = zlib_ZlibDecompressor_decompress_impl(self, &data, max_length);
     988                 :            : 
     989                 :          0 : exit:
     990                 :            :     /* Cleanup for data */
     991         [ #  # ]:          0 :     if (data.obj) {
     992                 :          0 :        PyBuffer_Release(&data);
     993                 :            :     }
     994                 :            : 
     995                 :          0 :     return return_value;
     996                 :            : }
     997                 :            : 
     998                 :            : PyDoc_STRVAR(zlib_adler32__doc__,
     999                 :            : "adler32($module, data, value=1, /)\n"
    1000                 :            : "--\n"
    1001                 :            : "\n"
    1002                 :            : "Compute an Adler-32 checksum of data.\n"
    1003                 :            : "\n"
    1004                 :            : "  value\n"
    1005                 :            : "    Starting value of the checksum.\n"
    1006                 :            : "\n"
    1007                 :            : "The returned checksum is an integer.");
    1008                 :            : 
    1009                 :            : #define ZLIB_ADLER32_METHODDEF    \
    1010                 :            :     {"adler32", _PyCFunction_CAST(zlib_adler32), METH_FASTCALL, zlib_adler32__doc__},
    1011                 :            : 
    1012                 :            : static PyObject *
    1013                 :            : zlib_adler32_impl(PyObject *module, Py_buffer *data, unsigned int value);
    1014                 :            : 
    1015                 :            : static PyObject *
    1016                 :          0 : zlib_adler32(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
    1017                 :            : {
    1018                 :          0 :     PyObject *return_value = NULL;
    1019                 :          0 :     Py_buffer data = {NULL, NULL};
    1020                 :          0 :     unsigned int value = 1;
    1021                 :            : 
    1022   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("adler32", nargs, 1, 2)) {
                   #  # ]
    1023                 :          0 :         goto exit;
    1024                 :            :     }
    1025         [ #  # ]:          0 :     if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
    1026                 :          0 :         goto exit;
    1027                 :            :     }
    1028         [ #  # ]:          0 :     if (!PyBuffer_IsContiguous(&data, 'C')) {
    1029                 :          0 :         _PyArg_BadArgument("adler32", "argument 1", "contiguous buffer", args[0]);
    1030                 :          0 :         goto exit;
    1031                 :            :     }
    1032         [ #  # ]:          0 :     if (nargs < 2) {
    1033                 :          0 :         goto skip_optional;
    1034                 :            :     }
    1035                 :          0 :     value = (unsigned int)PyLong_AsUnsignedLongMask(args[1]);
    1036   [ #  #  #  # ]:          0 :     if (value == (unsigned int)-1 && PyErr_Occurred()) {
    1037                 :          0 :         goto exit;
    1038                 :            :     }
    1039                 :          0 : skip_optional:
    1040                 :          0 :     return_value = zlib_adler32_impl(module, &data, value);
    1041                 :            : 
    1042                 :          0 : exit:
    1043                 :            :     /* Cleanup for data */
    1044         [ #  # ]:          0 :     if (data.obj) {
    1045                 :          0 :        PyBuffer_Release(&data);
    1046                 :            :     }
    1047                 :            : 
    1048                 :          0 :     return return_value;
    1049                 :            : }
    1050                 :            : 
    1051                 :            : PyDoc_STRVAR(zlib_crc32__doc__,
    1052                 :            : "crc32($module, data, value=0, /)\n"
    1053                 :            : "--\n"
    1054                 :            : "\n"
    1055                 :            : "Compute a CRC-32 checksum of data.\n"
    1056                 :            : "\n"
    1057                 :            : "  value\n"
    1058                 :            : "    Starting value of the checksum.\n"
    1059                 :            : "\n"
    1060                 :            : "The returned checksum is an integer.");
    1061                 :            : 
    1062                 :            : #define ZLIB_CRC32_METHODDEF    \
    1063                 :            :     {"crc32", _PyCFunction_CAST(zlib_crc32), METH_FASTCALL, zlib_crc32__doc__},
    1064                 :            : 
    1065                 :            : static unsigned int
    1066                 :            : zlib_crc32_impl(PyObject *module, Py_buffer *data, unsigned int value);
    1067                 :            : 
    1068                 :            : static PyObject *
    1069                 :          0 : zlib_crc32(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
    1070                 :            : {
    1071                 :          0 :     PyObject *return_value = NULL;
    1072                 :          0 :     Py_buffer data = {NULL, NULL};
    1073                 :          0 :     unsigned int value = 0;
    1074                 :            :     unsigned int _return_value;
    1075                 :            : 
    1076   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("crc32", nargs, 1, 2)) {
                   #  # ]
    1077                 :          0 :         goto exit;
    1078                 :            :     }
    1079         [ #  # ]:          0 :     if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
    1080                 :          0 :         goto exit;
    1081                 :            :     }
    1082         [ #  # ]:          0 :     if (!PyBuffer_IsContiguous(&data, 'C')) {
    1083                 :          0 :         _PyArg_BadArgument("crc32", "argument 1", "contiguous buffer", args[0]);
    1084                 :          0 :         goto exit;
    1085                 :            :     }
    1086         [ #  # ]:          0 :     if (nargs < 2) {
    1087                 :          0 :         goto skip_optional;
    1088                 :            :     }
    1089                 :          0 :     value = (unsigned int)PyLong_AsUnsignedLongMask(args[1]);
    1090   [ #  #  #  # ]:          0 :     if (value == (unsigned int)-1 && PyErr_Occurred()) {
    1091                 :          0 :         goto exit;
    1092                 :            :     }
    1093                 :          0 : skip_optional:
    1094                 :          0 :     _return_value = zlib_crc32_impl(module, &data, value);
    1095   [ #  #  #  # ]:          0 :     if ((_return_value == (unsigned int)-1) && PyErr_Occurred()) {
    1096                 :          0 :         goto exit;
    1097                 :            :     }
    1098                 :          0 :     return_value = PyLong_FromUnsignedLong((unsigned long)_return_value);
    1099                 :            : 
    1100                 :          0 : exit:
    1101                 :            :     /* Cleanup for data */
    1102         [ #  # ]:          0 :     if (data.obj) {
    1103                 :          0 :        PyBuffer_Release(&data);
    1104                 :            :     }
    1105                 :            : 
    1106                 :          0 :     return return_value;
    1107                 :            : }
    1108                 :            : 
    1109                 :            : #ifndef ZLIB_COMPRESS_COPY_METHODDEF
    1110                 :            :     #define ZLIB_COMPRESS_COPY_METHODDEF
    1111                 :            : #endif /* !defined(ZLIB_COMPRESS_COPY_METHODDEF) */
    1112                 :            : 
    1113                 :            : #ifndef ZLIB_COMPRESS___COPY___METHODDEF
    1114                 :            :     #define ZLIB_COMPRESS___COPY___METHODDEF
    1115                 :            : #endif /* !defined(ZLIB_COMPRESS___COPY___METHODDEF) */
    1116                 :            : 
    1117                 :            : #ifndef ZLIB_COMPRESS___DEEPCOPY___METHODDEF
    1118                 :            :     #define ZLIB_COMPRESS___DEEPCOPY___METHODDEF
    1119                 :            : #endif /* !defined(ZLIB_COMPRESS___DEEPCOPY___METHODDEF) */
    1120                 :            : 
    1121                 :            : #ifndef ZLIB_DECOMPRESS_COPY_METHODDEF
    1122                 :            :     #define ZLIB_DECOMPRESS_COPY_METHODDEF
    1123                 :            : #endif /* !defined(ZLIB_DECOMPRESS_COPY_METHODDEF) */
    1124                 :            : 
    1125                 :            : #ifndef ZLIB_DECOMPRESS___COPY___METHODDEF
    1126                 :            :     #define ZLIB_DECOMPRESS___COPY___METHODDEF
    1127                 :            : #endif /* !defined(ZLIB_DECOMPRESS___COPY___METHODDEF) */
    1128                 :            : 
    1129                 :            : #ifndef ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF
    1130                 :            :     #define ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF
    1131                 :            : #endif /* !defined(ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF) */
    1132                 :            : /*[clinic end generated code: output=57ff7b511ab23132 input=a9049054013a1b77]*/

Generated by: LCOV version 1.14