LCOV - code coverage report
Current view: | top level - Modules/clinic - _pickle.c.h (source / functions) |  |  | Hit | Total | Coverage
Test: | CPython 3.12 LCOV report [commit 5e6661bce9] |  | Lines: | 0 | 275 | 0.0 %
Date: | 2023-03-20 08:15:36 |  | Functions: | 0 | 17 | 0.0 %
|  |  | Branches: | 0 | 210 | 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(_pickle_Pickler_clear_memo__doc__,
          12                 :            : "clear_memo($self, /)\n"
          13                 :            : "--\n"
          14                 :            : "\n"
          15                 :            : "Clears the pickler\'s \"memo\".\n"
          16                 :            : "\n"
          17                 :            : "The memo is the data structure that remembers which objects the\n"
          18                 :            : "pickler has already seen, so that shared or recursive objects are\n"
          19                 :            : "pickled by reference and not by value.  This method is useful when\n"
          20                 :            : "re-using picklers.");
          21                 :            :
          22                 :            : #define _PICKLE_PICKLER_CLEAR_MEMO_METHODDEF    \
          23                 :            :     {"clear_memo", (PyCFunction)_pickle_Pickler_clear_memo, METH_NOARGS, _pickle_Pickler_clear_memo__doc__},
          24                 :            :
          25                 :            : static PyObject *
          26                 :            : _pickle_Pickler_clear_memo_impl(PicklerObject *self);
          27                 :            :
          28                 :            : static PyObject *
          29                 :          0 : _pickle_Pickler_clear_memo(PicklerObject *self, PyObject *Py_UNUSED(ignored))
          30                 :            : {
          31                 :          0 :     return _pickle_Pickler_clear_memo_impl(self);
          32                 :            : }
          33                 :            :
          34                 :            : PyDoc_STRVAR(_pickle_Pickler_dump__doc__,
          35                 :            : "dump($self, obj, /)\n"
          36                 :            : "--\n"
          37                 :            : "\n"
          38                 :            : "Write a pickled representation of the given object to the open file.");
          39                 :            :
          40                 :            : #define _PICKLE_PICKLER_DUMP_METHODDEF    \
          41                 :            :     {"dump", (PyCFunction)_pickle_Pickler_dump, METH_O, _pickle_Pickler_dump__doc__},
          42                 :            :
          43                 :            : PyDoc_STRVAR(_pickle_Pickler___sizeof____doc__,
          44                 :            : "__sizeof__($self, /)\n"
          45                 :            : "--\n"
          46                 :            : "\n"
          47                 :            : "Returns size in memory, in bytes.");
          48                 :            :
          49                 :            : #define _PICKLE_PICKLER___SIZEOF___METHODDEF    \
          50                 :            :     {"__sizeof__", (PyCFunction)_pickle_Pickler___sizeof__, METH_NOARGS, _pickle_Pickler___sizeof____doc__},
          51                 :            :
          52                 :            : static size_t
          53                 :            : _pickle_Pickler___sizeof___impl(PicklerObject *self);
          54                 :            :
          55                 :            : static PyObject *
          56                 :          0 : _pickle_Pickler___sizeof__(PicklerObject *self, PyObject *Py_UNUSED(ignored))
          57                 :            : {
          58                 :          0 :     PyObject *return_value = NULL;
          59                 :            :     size_t _return_value;
          60                 :            :
          61                 :          0 :     _return_value = _pickle_Pickler___sizeof___impl(self);
          62   [ #  #  #  # ]:          0 :     if ((_return_value == (size_t)-1) && PyErr_Occurred()) {
          63                 :          0 :         goto exit;
          64                 :            :     }
          65                 :          0 :     return_value = PyLong_FromSize_t(_return_value);
          66                 :            :
          67                 :          0 : exit:
          68                 :          0 :     return return_value;
          69                 :            : }
          70                 :            :
          71                 :            : PyDoc_STRVAR(_pickle_Pickler___init____doc__,
          72                 :            : "Pickler(file, protocol=None, fix_imports=True, buffer_callback=None)\n"
          73                 :            : "--\n"
          74                 :            : "\n"
          75                 :            : "This takes a binary file for writing a pickle data stream.\n"
          76                 :            : "\n"
          77                 :            : "The optional *protocol* argument tells the pickler to use the given\n"
          78                 :            : "protocol; supported protocols are 0, 1, 2, 3, 4 and 5.  The default\n"
          79                 :            : "protocol is 4. It was introduced in Python 3.4, and is incompatible\n"
          80                 :            : "with previous versions.\n"
          81                 :            : "\n"
          82                 :            : "Specifying a negative protocol version selects the highest protocol\n"
          83                 :            : "version supported.  The higher the protocol used, the more recent the\n"
          84                 :            : "version of Python needed to read the pickle produced.\n"
          85                 :            : "\n"
          86                 :            : "The *file* argument must have a write() method that accepts a single\n"
          87                 :            : "bytes argument. It can thus be a file object opened for binary\n"
          88                 :            : "writing, an io.BytesIO instance, or any other custom object that meets\n"
          89                 :            : "this interface.\n"
          90                 :            : "\n"
          91                 :            : "If *fix_imports* is True and protocol is less than 3, pickle will try\n"
          92                 :            : "to map the new Python 3 names to the old module names used in Python\n"
          93                 :            : "2, so that the pickle data stream is readable with Python 2.\n"
          94                 :            : "\n"
          95                 :            : "If *buffer_callback* is None (the default), buffer views are\n"
          96                 :            : "serialized into *file* as part of the pickle stream.\n"
          97                 :            : "\n"
          98                 :            : "If *buffer_callback* is not None, then it can be called any number\n"
          99                 :            : "of times with a buffer view.  If the callback returns a false value\n"
         100                 :            : "(such as None), the given buffer is out-of-band; otherwise the\n"
         101                 :            : "buffer is serialized in-band, i.e. inside the pickle stream.\n"
         102                 :            : "\n"
         103                 :            : "It is an error if *buffer_callback* is not None and *protocol*\n"
         104                 :            : "is None or smaller than 5.");
         105                 :            :
         106                 :            : static int
         107                 :            : _pickle_Pickler___init___impl(PicklerObject *self, PyObject *file,
         108                 :            :                               PyObject *protocol, int fix_imports,
         109                 :            :                               PyObject *buffer_callback);
         110                 :            :
         111                 :            : static int
         112                 :          0 : _pickle_Pickler___init__(PyObject *self, PyObject *args, PyObject *kwargs)
         113                 :            : {
         114                 :          0 :     int return_value = -1;
         115                 :            :     #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
         116                 :            :
         117                 :            :     #define NUM_KEYWORDS 4
         118                 :            :     static struct {
         119                 :            :         PyGC_Head _this_is_not_used;
         120                 :            :         PyObject_VAR_HEAD
         121                 :            :         PyObject *ob_item[NUM_KEYWORDS];
         122                 :            :     } _kwtuple = {
         123                 :            :         .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
         124                 :            :         .ob_item = { &_Py_ID(file), &_Py_ID(protocol), &_Py_ID(fix_imports), &_Py_ID(buffer_callback), },
         125                 :            :     };
         126                 :            :     #undef NUM_KEYWORDS
         127                 :            :     #define KWTUPLE (&_kwtuple.ob_base.ob_base)
         128                 :            :
         129                 :            :     #else  // !Py_BUILD_CORE
         130                 :            :     #  define KWTUPLE NULL
         131                 :            :     #endif  // !Py_BUILD_CORE
         132                 :            :
         133                 :            :     static const char * const _keywords[] = {"file", "protocol", "fix_imports", "buffer_callback", NULL};
         134                 :            :     static _PyArg_Parser _parser = {
         135                 :            :         .keywords = _keywords,
         136                 :            :         .fname = "Pickler",
         137                 :            :         .kwtuple = KWTUPLE,
         138                 :            :     };
         139                 :            :     #undef KWTUPLE
         140                 :            :     PyObject *argsbuf[4];
         141                 :            :     PyObject * const *fastargs;
         142                 :          0 :     Py_ssize_t nargs = PyTuple_GET_SIZE(args);
         143         [ #  # ]:          0 :     Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1;
         144                 :            :     PyObject *file;
         145                 :          0 :     PyObject *protocol = Py_None;
         146                 :          0 :     int fix_imports = 1;
         147                 :          0 :     PyObject *buffer_callback = Py_None;
         148                 :            :
         149   [ #  #  #  #  :          0 :     fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 4, 0, argsbuf);
                 #  #  #  # ]
         150         [ #  # ]:          0 :     if (!fastargs) {
         151                 :          0 :         goto exit;
         152                 :            :     }
         153                 :          0 :     file = fastargs[0];
         154         [ #  # ]:          0 :     if (!noptargs) {
         155                 :          0 :         goto skip_optional_pos;
         156                 :            :     }
         157         [ #  # ]:          0 :     if (fastargs[1]) {
         158                 :          0 :         protocol = fastargs[1];
         159         [ #  # ]:          0 :         if (!--noptargs) {
         160                 :          0 :             goto skip_optional_pos;
         161                 :            :         }
         162                 :            :     }
         163         [ #  # ]:          0 :     if (fastargs[2]) {
         164                 :          0 :         fix_imports = PyObject_IsTrue(fastargs[2]);
         165         [ #  # ]:          0 :         if (fix_imports < 0) {
         166                 :          0 :             goto exit;
         167                 :            :         }
         168         [ #  # ]:          0 :         if (!--noptargs) {
         169                 :          0 :             goto skip_optional_pos;
         170                 :            :         }
         171                 :            :     }
         172                 :          0 :     buffer_callback = fastargs[3];
         173                 :          0 : skip_optional_pos:
         174                 :          0 :     return_value = _pickle_Pickler___init___impl((PicklerObject *)self, file, protocol, fix_imports, buffer_callback);
         175                 :            :
         176                 :          0 : exit:
         177                 :          0 :     return return_value;
         178                 :            : }
         179                 :            :
         180                 :            : PyDoc_STRVAR(_pickle_PicklerMemoProxy_clear__doc__,
         181                 :            : "clear($self, /)\n"
         182                 :            : "--\n"
         183                 :            : "\n"
         184                 :            : "Remove all items from memo.");
         185                 :            :
         186                 :            : #define _PICKLE_PICKLERMEMOPROXY_CLEAR_METHODDEF    \
         187                 :            :     {"clear", (PyCFunction)_pickle_PicklerMemoProxy_clear, METH_NOARGS, _pickle_PicklerMemoProxy_clear__doc__},
         188                 :            :
         189                 :            : static PyObject *
         190                 :            : _pickle_PicklerMemoProxy_clear_impl(PicklerMemoProxyObject *self);
         191                 :            :
         192                 :            : static PyObject *
         193                 :          0 : _pickle_PicklerMemoProxy_clear(PicklerMemoProxyObject *self, PyObject *Py_UNUSED(ignored))
         194                 :            : {
         195                 :          0 :     return _pickle_PicklerMemoProxy_clear_impl(self);
         196                 :            : }
         197                 :            :
         198                 :            : PyDoc_STRVAR(_pickle_PicklerMemoProxy_copy__doc__,
         199                 :            : "copy($self, /)\n"
         200                 :            : "--\n"
         201                 :            : "\n"
         202                 :            : "Copy the memo to a new object.");
         203                 :            :
         204                 :            : #define _PICKLE_PICKLERMEMOPROXY_COPY_METHODDEF    \
         205                 :            :     {"copy", (PyCFunction)_pickle_PicklerMemoProxy_copy, METH_NOARGS, _pickle_PicklerMemoProxy_copy__doc__},
         206                 :            :
         207                 :            : static PyObject *
         208                 :            : _pickle_PicklerMemoProxy_copy_impl(PicklerMemoProxyObject *self);
         209                 :            :
         210                 :            : static PyObject *
         211                 :          0 : _pickle_PicklerMemoProxy_copy(PicklerMemoProxyObject *self, PyObject *Py_UNUSED(ignored))
         212                 :            : {
         213                 :          0 :     return _pickle_PicklerMemoProxy_copy_impl(self);
         214                 :            : }
         215                 :            :
         216                 :            : PyDoc_STRVAR(_pickle_PicklerMemoProxy___reduce____doc__,
         217                 :            : "__reduce__($self, /)\n"
         218                 :            : "--\n"
         219                 :            : "\n"
         220                 :            : "Implement pickle support.");
         221                 :            :
         222                 :            : #define _PICKLE_PICKLERMEMOPROXY___REDUCE___METHODDEF    \
         223                 :            :     {"__reduce__", (PyCFunction)_pickle_PicklerMemoProxy___reduce__, METH_NOARGS, _pickle_PicklerMemoProxy___reduce____doc__},
         224                 :            :
         225                 :            : static PyObject *
         226                 :            : _pickle_PicklerMemoProxy___reduce___impl(PicklerMemoProxyObject *self);
         227                 :            :
         228                 :            : static PyObject *
         229                 :          0 : _pickle_PicklerMemoProxy___reduce__(PicklerMemoProxyObject *self, PyObject *Py_UNUSED(ignored))
         230                 :            : {
         231                 :          0 :     return _pickle_PicklerMemoProxy___reduce___impl(self);
         232                 :            : }
         233                 :            :
         234                 :            : PyDoc_STRVAR(_pickle_Unpickler_load__doc__,
         235                 :            : "load($self, /)\n"
         236                 :            : "--\n"
         237                 :            : "\n"
         238                 :            : "Load a pickle.\n"
         239                 :            : "\n"
         240                 :            : "Read a pickled object representation from the open file object given\n"
         241                 :            : "in the constructor, and return the reconstituted object hierarchy\n"
         242                 :            : "specified therein.");
         243                 :            :
         244                 :            : #define _PICKLE_UNPICKLER_LOAD_METHODDEF    \
         245                 :            :     {"load", (PyCFunction)_pickle_Unpickler_load, METH_NOARGS, _pickle_Unpickler_load__doc__},
         246                 :            :
         247                 :            : static PyObject *
         248                 :            : _pickle_Unpickler_load_impl(UnpicklerObject *self);
         249                 :            :
         250                 :            : static PyObject *
         251                 :          0 : _pickle_Unpickler_load(UnpicklerObject *self, PyObject *Py_UNUSED(ignored))
         252                 :            : {
         253                 :          0 :     return _pickle_Unpickler_load_impl(self);
         254                 :            : }
         255                 :            :
         256                 :            : PyDoc_STRVAR(_pickle_Unpickler_find_class__doc__,
         257                 :            : "find_class($self, module_name, global_name, /)\n"
         258                 :            : "--\n"
         259                 :            : "\n"
         260                 :            : "Return an object from a specified module.\n"
         261                 :            : "\n"
         262                 :            : "If necessary, the module will be imported. Subclasses may override\n"
         263                 :            : "this method (e.g. to restrict unpickling of arbitrary classes and\n"
         264                 :            : "functions).\n"
         265                 :            : "\n"
         266                 :            : "This method is called whenever a class or a function object is\n"
         267                 :            : "needed.  Both arguments passed are str objects.");
         268                 :            :
         269                 :            : #define _PICKLE_UNPICKLER_FIND_CLASS_METHODDEF    \
         270                 :            :     {"find_class", _PyCFunction_CAST(_pickle_Unpickler_find_class), METH_FASTCALL, _pickle_Unpickler_find_class__doc__},
         271                 :            :
         272                 :            : static PyObject *
         273                 :            : _pickle_Unpickler_find_class_impl(UnpicklerObject *self,
         274                 :            :                                   PyObject *module_name,
         275                 :            :                                   PyObject *global_name);
         276                 :            :
         277                 :            : static PyObject *
         278                 :          0 : _pickle_Unpickler_find_class(UnpicklerObject *self, PyObject *const *args, Py_ssize_t nargs)
         279                 :            : {
         280                 :          0 :     PyObject *return_value = NULL;
         281                 :            :     PyObject *module_name;
         282                 :            :     PyObject *global_name;
         283                 :            :
         284   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("find_class", nargs, 2, 2)) {
                       #  # ]
         285                 :          0 :         goto exit;
         286                 :            :     }
         287                 :          0 :     module_name = args[0];
         288                 :          0 :     global_name = args[1];
         289                 :          0 :     return_value = _pickle_Unpickler_find_class_impl(self, module_name, global_name);
         290                 :            :
         291                 :          0 : exit:
         292                 :          0 :     return return_value;
         293                 :            : }
         294                 :            :
         295                 :            : PyDoc_STRVAR(_pickle_Unpickler___sizeof____doc__,
         296                 :            : "__sizeof__($self, /)\n"
         297                 :            : "--\n"
         298                 :            : "\n"
         299                 :            : "Returns size in memory, in bytes.");
         300                 :            :
         301                 :            : #define _PICKLE_UNPICKLER___SIZEOF___METHODDEF    \
         302                 :            :     {"__sizeof__", (PyCFunction)_pickle_Unpickler___sizeof__, METH_NOARGS, _pickle_Unpickler___sizeof____doc__},
         303                 :            :
         304                 :            : static size_t
         305                 :            : _pickle_Unpickler___sizeof___impl(UnpicklerObject *self);
         306                 :            :
         307                 :            : static PyObject *
         308                 :          0 : _pickle_Unpickler___sizeof__(UnpicklerObject *self, PyObject *Py_UNUSED(ignored))
         309                 :            : {
         310                 :          0 :     PyObject *return_value = NULL;
         311                 :            :     size_t _return_value;
         312                 :            :
         313                 :          0 :     _return_value = _pickle_Unpickler___sizeof___impl(self);
         314   [ #  #  #  # ]:          0 :     if ((_return_value == (size_t)-1) && PyErr_Occurred()) {
         315                 :          0 :         goto exit;
         316                 :            :     }
         317                 :          0 :     return_value = PyLong_FromSize_t(_return_value);
         318                 :            :
         319                 :          0 : exit:
         320                 :          0 :     return return_value;
         321                 :            : }
         322                 :            :
         323                 :            : PyDoc_STRVAR(_pickle_Unpickler___init____doc__,
         324                 :            : "Unpickler(file, *, fix_imports=True, encoding=\'ASCII\', errors=\'strict\',\n"
         325                 :            : "          buffers=())\n"
         326                 :            : "--\n"
         327                 :            : "\n"
         328                 :            : "This takes a binary file for reading a pickle data stream.\n"
         329                 :            : "\n"
         330                 :            : "The protocol version of the pickle is detected automatically, so no\n"
         331                 :            : "protocol argument is needed.  Bytes past the pickled object\'s\n"
         332                 :            : "representation are ignored.\n"
         333                 :            : "\n"
         334                 :            : "The argument *file* must have two methods, a read() method that takes\n"
         335                 :            : "an integer argument, and a readline() method that requires no\n"
         336                 :            : "arguments.  Both methods should return bytes.  Thus *file* can be a\n"
         337                 :            : "binary file object opened for reading, an io.BytesIO object, or any\n"
         338                 :            : "other custom object that meets this interface.\n"
         339                 :            : "\n"
         340                 :            : "Optional keyword arguments are *fix_imports*, *encoding* and *errors*,\n"
         341                 :            : "which are used to control compatibility support for pickle stream\n"
         342                 :            : "generated by Python 2.  If *fix_imports* is True, pickle will try to\n"
         343                 :            : "map the old Python 2 names to the new names used in Python 3.  The\n"
         344                 :            : "*encoding* and *errors* tell pickle how to decode 8-bit string\n"
         345                 :            : "instances pickled by Python 2; these default to \'ASCII\' and \'strict\',\n"
         346                 :            : "respectively.  The *encoding* can be \'bytes\' to read these 8-bit\n"
         347                 :            : "string instances as bytes objects.");
         348                 :            :
         349                 :            : static int
         350                 :            : _pickle_Unpickler___init___impl(UnpicklerObject *self, PyObject *file,
         351                 :            :                                 int fix_imports, const char *encoding,
         352                 :            :                                 const char *errors, PyObject *buffers);
         353                 :            :
         354                 :            : static int
         355                 :          0 : _pickle_Unpickler___init__(PyObject *self, PyObject *args, PyObject *kwargs)
         356                 :            : {
         357                 :          0 :     int return_value = -1;
         358                 :            :     #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
         359                 :            :
         360                 :            :     #define NUM_KEYWORDS 5
         361                 :            :     static struct {
         362                 :            :         PyGC_Head _this_is_not_used;
         363                 :            :         PyObject_VAR_HEAD
         364                 :            :         PyObject *ob_item[NUM_KEYWORDS];
         365                 :            :     } _kwtuple = {
         366                 :            :         .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
         367                 :            :         .ob_item = { &_Py_ID(file), &_Py_ID(fix_imports), &_Py_ID(encoding), &_Py_ID(errors), &_Py_ID(buffers), },
         368                 :            :     };
         369                 :            :     #undef NUM_KEYWORDS
         370                 :            :     #define KWTUPLE (&_kwtuple.ob_base.ob_base)
         371                 :            :
         372                 :            :     #else  // !Py_BUILD_CORE
         373                 :            :     #  define KWTUPLE NULL
         374                 :            :     #endif  // !Py_BUILD_CORE
         375                 :            :
         376                 :            :     static const char * const _keywords[] = {"file", "fix_imports", "encoding", "errors", "buffers", NULL};
         377                 :            :     static _PyArg_Parser _parser = {
         378                 :            :         .keywords = _keywords,
         379                 :            :         .fname = "Unpickler",
         380                 :            :         .kwtuple = KWTUPLE,
         381                 :            :     };
         382                 :            :     #undef KWTUPLE
         383                 :            :     PyObject *argsbuf[5];
         384                 :            :     PyObject * const *fastargs;
         385                 :          0 :     Py_ssize_t nargs = PyTuple_GET_SIZE(args);
         386         [ #  # ]:          0 :     Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1;
         387                 :            :     PyObject *file;
         388                 :          0 :     int fix_imports = 1;
         389                 :          0 :     const char *encoding = "ASCII";
         390                 :          0 :     const char *errors = "strict";
         391                 :          0 :     PyObject *buffers = NULL;
         392                 :            :
         393   [ #  #  #  #  :          0 :     fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 1, 0, argsbuf);
                 #  #  #  # ]
         394         [ #  # ]:          0 :     if (!fastargs) {
         395                 :          0 :         goto exit;
         396                 :            :     }
         397                 :          0 :     file = fastargs[0];
         398         [ #  # ]:          0 :     if (!noptargs) {
         399                 :          0 :         goto skip_optional_kwonly;
         400                 :            :     }
         401         [ #  # ]:          0 :     if (fastargs[1]) {
         402                 :          0 :         fix_imports = PyObject_IsTrue(fastargs[1]);
         403         [ #  # ]:          0 :         if (fix_imports < 0) {
         404                 :          0 :             goto exit;
         405                 :            :         }
         406         [ #  # ]:          0 :         if (!--noptargs) {
         407                 :          0 :             goto skip_optional_kwonly;
         408                 :            :         }
         409                 :            :     }
         410         [ #  # ]:          0 :     if (fastargs[2]) {
         411         [ #  # ]:          0 :         if (!PyUnicode_Check(fastargs[2])) {
         412                 :          0 :             _PyArg_BadArgument("Unpickler", "argument 'encoding'", "str", fastargs[2]);
         413                 :          0 :             goto exit;
         414                 :            :         }
         415                 :            :         Py_ssize_t encoding_length;
         416                 :          0 :         encoding = PyUnicode_AsUTF8AndSize(fastargs[2], &encoding_length);
         417         [ #  # ]:          0 :         if (encoding == NULL) {
         418                 :          0 :             goto exit;
         419                 :            :         }
         420         [ #  # ]:          0 :         if (strlen(encoding) != (size_t)encoding_length) {
         421                 :          0 :             PyErr_SetString(PyExc_ValueError, "embedded null character");
         422                 :          0 :             goto exit;
         423                 :            :         }
         424         [ #  # ]:          0 :         if (!--noptargs) {
         425                 :          0 :             goto skip_optional_kwonly;
         426                 :            :         }
         427                 :            :     }
         428         [ #  # ]:          0 :     if (fastargs[3]) {
         429         [ #  # ]:          0 :         if (!PyUnicode_Check(fastargs[3])) {
         430                 :          0 :             _PyArg_BadArgument("Unpickler", "argument 'errors'", "str", fastargs[3]);
         431                 :          0 :             goto exit;
         432                 :            :         }
         433                 :            :         Py_ssize_t errors_length;
         434                 :          0 :         errors = PyUnicode_AsUTF8AndSize(fastargs[3], &errors_length);
         435         [ #  # ]:          0 :         if (errors == NULL) {
         436                 :          0 :             goto exit;
         437                 :            :         }
         438         [ #  # ]:          0 :         if (strlen(errors) != (size_t)errors_length) {
         439                 :          0 :             PyErr_SetString(PyExc_ValueError, "embedded null character");
         440                 :          0 :             goto exit;
         441                 :            :         }
         442         [ #  # ]:          0 :         if (!--noptargs) {
         443                 :          0 :             goto skip_optional_kwonly;
         444                 :            :         }
         445                 :            :     }
         446                 :          0 :     buffers = fastargs[4];
         447                 :          0 : skip_optional_kwonly:
         448                 :          0 :     return_value = _pickle_Unpickler___init___impl((UnpicklerObject *)self, file, fix_imports, encoding, errors, buffers);
         449                 :            :
         450                 :          0 : exit:
         451                 :          0 :     return return_value;
         452                 :            : }
         453                 :            :
         454                 :            : PyDoc_STRVAR(_pickle_UnpicklerMemoProxy_clear__doc__,
         455                 :            : "clear($self, /)\n"
         456                 :            : "--\n"
         457                 :            : "\n"
         458                 :            : "Remove all items from memo.");
         459                 :            :
         460                 :            : #define _PICKLE_UNPICKLERMEMOPROXY_CLEAR_METHODDEF    \
         461                 :            :     {"clear", (PyCFunction)_pickle_UnpicklerMemoProxy_clear, METH_NOARGS, _pickle_UnpicklerMemoProxy_clear__doc__},
         462                 :            :
         463                 :            : static PyObject *
         464                 :            : _pickle_UnpicklerMemoProxy_clear_impl(UnpicklerMemoProxyObject *self);
         465                 :            :
         466                 :            : static PyObject *
         467                 :          0 : _pickle_UnpicklerMemoProxy_clear(UnpicklerMemoProxyObject *self, PyObject *Py_UNUSED(ignored))
         468                 :            : {
         469                 :          0 :     return _pickle_UnpicklerMemoProxy_clear_impl(self);
         470                 :            : }
         471                 :            :
         472                 :            : PyDoc_STRVAR(_pickle_UnpicklerMemoProxy_copy__doc__,
         473                 :            : "copy($self, /)\n"
         474                 :            : "--\n"
         475                 :            : "\n"
         476                 :            : "Copy the memo to a new object.");
         477                 :            :
         478                 :            : #define _PICKLE_UNPICKLERMEMOPROXY_COPY_METHODDEF    \
         479                 :            :     {"copy", (PyCFunction)_pickle_UnpicklerMemoProxy_copy, METH_NOARGS, _pickle_UnpicklerMemoProxy_copy__doc__},
         480                 :            :
         481                 :            : static PyObject *
         482                 :            : _pickle_UnpicklerMemoProxy_copy_impl(UnpicklerMemoProxyObject *self);
         483                 :            :
         484                 :            : static PyObject *
         485                 :          0 : _pickle_UnpicklerMemoProxy_copy(UnpicklerMemoProxyObject *self, PyObject *Py_UNUSED(ignored))
         486                 :            : {
         487                 :          0 :     return _pickle_UnpicklerMemoProxy_copy_impl(self);
         488                 :            : }
         489                 :            :
         490                 :            : PyDoc_STRVAR(_pickle_UnpicklerMemoProxy___reduce____doc__,
         491                 :            : "__reduce__($self, /)\n"
         492                 :            : "--\n"
         493                 :            : "\n"
         494                 :            : "Implement pickling support.");
         495                 :            :
         496                 :            : #define _PICKLE_UNPICKLERMEMOPROXY___REDUCE___METHODDEF    \
         497                 :            :     {"__reduce__", (PyCFunction)_pickle_UnpicklerMemoProxy___reduce__, METH_NOARGS, _pickle_UnpicklerMemoProxy___reduce____doc__},
         498                 :            :
         499                 :            : static PyObject *
         500                 :            : _pickle_UnpicklerMemoProxy___reduce___impl(UnpicklerMemoProxyObject *self);
         501                 :            :
         502                 :            : static PyObject *
         503                 :          0 : _pickle_UnpicklerMemoProxy___reduce__(UnpicklerMemoProxyObject *self, PyObject *Py_UNUSED(ignored))
         504                 :            : {
         505                 :          0 :     return _pickle_UnpicklerMemoProxy___reduce___impl(self);
         506                 :            : }
         507                 :            :
         508                 :            : PyDoc_STRVAR(_pickle_dump__doc__,
         509                 :            : "dump($module, /, obj, file, protocol=None, *, fix_imports=True,\n"
         510                 :            : "     buffer_callback=None)\n"
         511                 :            : "--\n"
         512                 :            : "\n"
         513                 :            : "Write a pickled representation of obj to the open file object file.\n"
         514                 :            : "\n"
         515                 :            : "This is equivalent to ``Pickler(file, protocol).dump(obj)``, but may\n"
         516                 :            : "be more efficient.\n"
         517                 :            : "\n"
         518                 :            : "The optional *protocol* argument tells the pickler to use the given\n"
         519                 :            : "protocol; supported protocols are 0, 1, 2, 3, 4 and 5.  The default\n"
         520                 :            : "protocol is 4. It was introduced in Python 3.4, and is incompatible\n"
         521                 :            : "with previous versions.\n"
         522                 :            : "\n"
         523                 :            : "Specifying a negative protocol version selects the highest protocol\n"
         524                 :            : "version supported.  The higher the protocol used, the more recent the\n"
         525                 :            : "version of Python needed to read the pickle produced.\n"
         526                 :            : "\n"
         527                 :            : "The *file* argument must have a write() method that accepts a single\n"
         528                 :            : "bytes argument.  It can thus be a file object opened for binary\n"
         529                 :            : "writing, an io.BytesIO instance, or any other custom object that meets\n"
         530                 :            : "this interface.\n"
         531                 :            : "\n"
         532                 :            : "If *fix_imports* is True and protocol is less than 3, pickle will try\n"
         533                 :            : "to map the new Python 3 names to the old module names used in Python\n"
         534                 :            : "2, so that the pickle data stream is readable with Python 2.\n"
         535                 :            : "\n"
         536                 :            : "If *buffer_callback* is None (the default), buffer views are serialized\n"
         537                 :            : "into *file* as part of the pickle stream.  It is an error if\n"
         538                 :            : "*buffer_callback* is not None and *protocol* is None or smaller than 5.");
         539                 :            :
         540                 :            : #define _PICKLE_DUMP_METHODDEF    \
         541                 :            :     {"dump", _PyCFunction_CAST(_pickle_dump), METH_FASTCALL|METH_KEYWORDS, _pickle_dump__doc__},
         542                 :            :
         543                 :            : static PyObject *
         544                 :            : _pickle_dump_impl(PyObject *module, PyObject *obj, PyObject *file,
         545                 :            :                   PyObject *protocol, int fix_imports,
         546                 :            :                   PyObject *buffer_callback);
         547                 :            :
         548                 :            : static PyObject *
         549                 :          0 : _pickle_dump(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
         550                 :            : {
         551                 :          0 :     PyObject *return_value = NULL;
         552                 :            :     #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
         553                 :            :
         554                 :            :     #define NUM_KEYWORDS 5
         555                 :            :     static struct {
         556                 :            :         PyGC_Head _this_is_not_used;
         557                 :            :         PyObject_VAR_HEAD
         558                 :            :         PyObject *ob_item[NUM_KEYWORDS];
         559                 :            :     } _kwtuple = {
         560                 :            :         .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
         561                 :            :         .ob_item = { &_Py_ID(obj), &_Py_ID(file), &_Py_ID(protocol), &_Py_ID(fix_imports), &_Py_ID(buffer_callback), },
         562                 :            :     };
         563                 :            :     #undef NUM_KEYWORDS
         564                 :            :     #define KWTUPLE (&_kwtuple.ob_base.ob_base)
         565                 :            :
         566                 :            :     #else  // !Py_BUILD_CORE
         567                 :            :     #  define KWTUPLE NULL
         568                 :            :     #endif  // !Py_BUILD_CORE
         569                 :            :
         570                 :            :     static const char * const _keywords[] = {"obj", "file", "protocol", "fix_imports", "buffer_callback", NULL};
         571                 :            :     static _PyArg_Parser _parser = {
         572                 :            :         .keywords = _keywords,
         573                 :            :         .fname = "dump",
         574                 :            :         .kwtuple = KWTUPLE,
         575                 :            :     };
         576                 :            :     #undef KWTUPLE
         577                 :            :     PyObject *argsbuf[5];
         578         [ #  # ]:          0 :     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2;
         579                 :            :     PyObject *obj;
         580                 :            :     PyObject *file;
         581                 :          0 :     PyObject *protocol = Py_None;
         582                 :          0 :     int fix_imports = 1;
         583                 :          0 :     PyObject *buffer_callback = Py_None;
         584                 :            :
         585   [ #  #  #  #  :          0 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf);
                 #  #  #  # ]
         586         [ #  # ]:          0 :     if (!args) {
         587                 :          0 :         goto exit;
         588                 :            :     }
         589                 :          0 :     obj = args[0];
         590                 :          0 :     file = args[1];
         591         [ #  # ]:          0 :     if (!noptargs) {
         592                 :          0 :         goto skip_optional_pos;
         593                 :            :     }
         594         [ #  # ]:          0 :     if (args[2]) {
         595                 :          0 :         protocol = args[2];
         596         [ #  # ]:          0 :         if (!--noptargs) {
         597                 :          0 :             goto skip_optional_pos;
         598                 :            :         }
         599                 :            :     }
         600                 :          0 : skip_optional_pos:
         601         [ #  # ]:          0 :     if (!noptargs) {
         602                 :          0 :         goto skip_optional_kwonly;
         603                 :            :     }
         604         [ #  # ]:          0 :     if (args[3]) {
         605                 :          0 :         fix_imports = PyObject_IsTrue(args[3]);
         606         [ #  # ]:          0 :         if (fix_imports < 0) {
         607                 :          0 :             goto exit;
         608                 :            :         }
         609         [ #  # ]:          0 :         if (!--noptargs) {
         610                 :          0 :             goto skip_optional_kwonly;
         611                 :            :         }
         612                 :            :     }
         613                 :          0 :     buffer_callback = args[4];
         614                 :          0 : skip_optional_kwonly:
         615                 :          0 :     return_value = _pickle_dump_impl(module, obj, file, protocol, fix_imports, buffer_callback);
         616                 :            :
         617                 :          0 : exit:
         618                 :          0 :     return return_value;
         619                 :            : }
         620                 :            :
         621                 :            : PyDoc_STRVAR(_pickle_dumps__doc__,
         622                 :            : "dumps($module, /, obj, protocol=None, *, fix_imports=True,\n"
         623                 :            : "      buffer_callback=None)\n"
         624                 :            : "--\n"
         625                 :            : "\n"
         626                 :            : "Return the pickled representation of the object as a bytes object.\n"
         627                 :            : "\n"
         628                 :            : "The optional *protocol* argument tells the pickler to use the given\n"
         629                 :            : "protocol; supported protocols are 0, 1, 2, 3, 4 and 5.  The default\n"
         630                 :            : "protocol is 4. It was introduced in Python 3.4, and is incompatible\n"
         631                 :            : "with previous versions.\n"
         632                 :            : "\n"
         633                 :            : "Specifying a negative protocol version selects the highest protocol\n"
         634                 :            : "version supported.  The higher the protocol used, the more recent the\n"
         635                 :            : "version of Python needed to read the pickle produced.\n"
         636                 :            : "\n"
         637                 :            : "If *fix_imports* is True and *protocol* is less than 3, pickle will\n"
         638                 :            : "try to map the new Python 3 names to the old module names used in\n"
         639                 :            : "Python 2, so that the pickle data stream is readable with Python 2.\n"
         640                 :            : "\n"
         641                 :            : "If *buffer_callback* is None (the default), buffer views are serialized\n"
         642                 :            : "into *file* as part of the pickle stream.  It is an error if\n"
         643                 :            : "*buffer_callback* is not None and *protocol* is None or smaller than 5.");
         644                 :            :
         645                 :            : #define _PICKLE_DUMPS_METHODDEF    \
         646                 :            :     {"dumps", _PyCFunction_CAST(_pickle_dumps), METH_FASTCALL|METH_KEYWORDS, _pickle_dumps__doc__},
         647                 :            :
         648                 :            : static PyObject *
         649                 :            : _pickle_dumps_impl(PyObject *module, PyObject *obj, PyObject *protocol,
         650                 :            :                    int fix_imports, PyObject *buffer_callback);
         651                 :            :
         652                 :            : static PyObject *
         653                 :          0 : _pickle_dumps(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
         654                 :            : {
         655                 :          0 :     PyObject *return_value = NULL;
         656                 :            :     #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
         657                 :            :
         658                 :            :     #define NUM_KEYWORDS 4
         659                 :            :     static struct {
         660                 :            :         PyGC_Head _this_is_not_used;
         661                 :            :         PyObject_VAR_HEAD
         662                 :            :         PyObject *ob_item[NUM_KEYWORDS];
         663                 :            :     } _kwtuple = {
         664                 :            :         .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
         665                 :            :         .ob_item = { &_Py_ID(obj), &_Py_ID(protocol), &_Py_ID(fix_imports), &_Py_ID(buffer_callback), },
         666                 :            :     };
         667                 :            :     #undef NUM_KEYWORDS
         668                 :            :     #define KWTUPLE (&_kwtuple.ob_base.ob_base)
         669                 :            :
         670                 :            :     #else  // !Py_BUILD_CORE
         671                 :            :     #  define KWTUPLE NULL
         672                 :            :     #endif  // !Py_BUILD_CORE
         673                 :            :
         674                 :            :     static const char * const _keywords[] = {"obj", "protocol", "fix_imports", "buffer_callback", NULL};
         675                 :            :     static _PyArg_Parser _parser = {
         676                 :            :         .keywords = _keywords,
         677                 :            :         .fname = "dumps",
         678                 :            :         .kwtuple = KWTUPLE,
         679                 :            :     };
         680                 :            :     #undef KWTUPLE
         681                 :            :     PyObject *argsbuf[4];
         682         [ #  # ]:          0 :     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
         683                 :            :     PyObject *obj;
         684                 :          0 :     PyObject *protocol = Py_None;
         685                 :          0 :     int fix_imports = 1;
         686                 :          0 :     PyObject *buffer_callback = Py_None;
         687                 :            :
         688   [ #  #  #  #  :          0 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
                 #  #  #  # ]
         689         [ #  # ]:          0 :     if (!args) {
         690                 :          0 :         goto exit;
         691                 :            :     }
         692                 :          0 :     obj = args[0];
         693         [ #  # ]:          0 :     if (!noptargs) {
         694                 :          0 :         goto skip_optional_pos;
         695                 :            :     }
         696         [ #  # ]:          0 :     if (args[1]) {
         697                 :          0 :         protocol = args[1];
         698         [ #  # ]:          0 :         if (!--noptargs) {
         699                 :          0 :             goto skip_optional_pos;
         700                 :            :         }
         701                 :            :     }
         702                 :          0 : skip_optional_pos:
         703         [ #  # ]:          0 :     if (!noptargs) {
         704                 :          0 :         goto skip_optional_kwonly;
         705                 :            :     }
         706         [ #  # ]:          0 :     if (args[2]) {
         707                 :          0 :         fix_imports = PyObject_IsTrue(args[2]);
         708         [ #  # ]:          0 :         if (fix_imports < 0) {
         709                 :          0 :             goto exit;
         710                 :            :         }
         711         [ #  # ]:          0 :         if (!--noptargs) {
         712                 :          0 :             goto skip_optional_kwonly;
         713                 :            :         }
         714                 :            :     }
         715                 :          0 :     buffer_callback = args[3];
         716                 :          0 : skip_optional_kwonly:
         717                 :          0 :     return_value = _pickle_dumps_impl(module, obj, protocol, fix_imports, buffer_callback);
         718                 :            :
         719                 :          0 : exit:
         720                 :          0 :     return return_value;
         721                 :            : }
         722                 :            :
         723                 :            : PyDoc_STRVAR(_pickle_load__doc__,
         724                 :            : "load($module, /, file, *, fix_imports=True, encoding=\'ASCII\',\n"
         725                 :            : "     errors=\'strict\', buffers=())\n"
         726                 :            : "--\n"
         727                 :            : "\n"
         728                 :            : "Read and return an object from the pickle data stored in a file.\n"
         729                 :            : "\n"
         730                 :            : "This is equivalent to ``Unpickler(file).load()``, but may be more\n"
         731                 :            : "efficient.\n"
         732                 :            : "\n"
         733                 :            : "The protocol version of the pickle is detected automatically, so no\n"
         734                 :            : "protocol argument is needed.  Bytes past the pickled object\'s\n"
         735                 :            : "representation are ignored.\n"
         736                 :            : "\n"
         737                 :            : "The argument *file* must have two methods, a read() method that takes\n"
         738                 :            : "an integer argument, and a readline() method that requires no\n"
         739                 :            : "arguments.  Both methods should return bytes.  Thus *file* can be a\n"
         740                 :            : "binary file object opened for reading, an io.BytesIO object, or any\n"
         741                 :            : "other custom object that meets this interface.\n"
         742                 :            : "\n"
         743                 :            : "Optional keyword arguments are *fix_imports*, *encoding* and *errors*,\n"
         744                 :            : "which are used to control compatibility support for pickle stream\n"
         745                 :            : "generated by Python 2.  If *fix_imports* is True, pickle will try to\n"
         746                 :            : "map the old Python 2 names to the new names used in Python 3.  The\n"
         747                 :            : "*encoding* and *errors* tell pickle how to decode 8-bit string\n"
         748                 :            : "instances pickled by Python 2; these default to \'ASCII\' and \'strict\',\n"
         749                 :            : "respectively.  The *encoding* can be \'bytes\' to read these 8-bit\n"
         750                 :            : "string instances as bytes objects.");
         751                 :            :
         752                 :            : #define _PICKLE_LOAD_METHODDEF    \
         753                 :            :     {"load", _PyCFunction_CAST(_pickle_load), METH_FASTCALL|METH_KEYWORDS, _pickle_load__doc__},
         754                 :            :
         755                 :            : static PyObject *
         756                 :            : _pickle_load_impl(PyObject *module, PyObject *file, int fix_imports,
         757                 :            :                   const char *encoding, const char *errors,
         758                 :            :                   PyObject *buffers);
         759                 :            :
         760                 :            : static PyObject *
         761                 :          0 : _pickle_load(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
         762                 :            : {
         763                 :          0 :     PyObject *return_value = NULL;
         764                 :            :     #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
         765                 :            :
         766                 :            :     #define NUM_KEYWORDS 5
         767                 :            :     static struct {
         768                 :            :         PyGC_Head _this_is_not_used;
         769                 :            :         PyObject_VAR_HEAD
         770                 :            :         PyObject *ob_item[NUM_KEYWORDS];
         771                 :            :     } _kwtuple = {
         772                 :            :         .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
         773                 :            :         .ob_item = { &_Py_ID(file), &_Py_ID(fix_imports), &_Py_ID(encoding), &_Py_ID(errors), &_Py_ID(buffers), },
         774                 :            :     };
         775                 :            :     #undef NUM_KEYWORDS
         776                 :            :     #define KWTUPLE (&_kwtuple.ob_base.ob_base)
         777                 :            :
         778                 :            :     #else  // !Py_BUILD_CORE
         779                 :            :     #  define KWTUPLE NULL
         780                 :            :     #endif  // !Py_BUILD_CORE
         781                 :            :
         782                 :            :     static const char * const _keywords[] = {"file", "fix_imports", "encoding", "errors", "buffers", NULL};
         783                 :            :     static _PyArg_Parser _parser = {
         784                 :            :         .keywords = _keywords,
         785                 :            :         .fname = "load",
         786                 :            :         .kwtuple = KWTUPLE,
         787                 :            :     };
         788                 :            :     #undef KWTUPLE
         789                 :            :     PyObject *argsbuf[5];
         790         [ #  # ]:          0 :     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
         791                 :            :     PyObject *file;
         792                 :          0 :     int fix_imports = 1;
         793                 :          0 :     const char *encoding = "ASCII";
         794                 :          0 :     const char *errors = "strict";
         795                 :          0 :     PyObject *buffers = NULL;
         796                 :            :
         797   [ #  #  #  #  :          0 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
                 #  #  #  # ]
         798         [ #  # ]:          0 :     if (!args) {
         799                 :          0 :         goto exit;
         800                 :            :     }
         801                 :          0 :     file = args[0];
         802         [ #  # ]:          0 :     if (!noptargs) {
         803                 :          0 :         goto skip_optional_kwonly;
         804                 :            :     }
         805         [ #  # ]:          0 :     if (args[1]) {
         806                 :          0 :         fix_imports = PyObject_IsTrue(args[1]);
         807         [ #  # ]:          0 :         if (fix_imports < 0) {
         808                 :          0 :             goto exit;
         809                 :            :         }
         810         [ #  # ]:          0 :         if (!--noptargs) {
         811                 :          0 :             goto skip_optional_kwonly;
         812                 :            :         }
         813                 :            :     }
         814         [ #  # ]:          0 :     if (args[2]) {
         815         [ #  # ]:          0 :         if (!PyUnicode_Check(args[2])) {
         816                 :          0 :             _PyArg_BadArgument("load", "argument 'encoding'", "str", args[2]);
         817                 :          0 :             goto exit;
         818                 :            :         }
         819                 :            :         Py_ssize_t encoding_length;
         820                 :          0 :         encoding = PyUnicode_AsUTF8AndSize(args[2], &encoding_length);
         821         [ #  # ]:          0 :         if (encoding == NULL) {
         822                 :          0 :             goto exit;
         823                 :            :         }
         824         [ #  # ]:          0 :         if (strlen(encoding) != (size_t)encoding_length) {
         825                 :          0 :             PyErr_SetString(PyExc_ValueError, "embedded null character");
         826                 :          0 :             goto exit;
         827                 :            :         }
         828         [ #  # ]:          0 :         if (!--noptargs) {
         829                 :          0 :             goto skip_optional_kwonly;
         830                 :            :         }
         831                 :            :     }
         832         [ #  # ]:          0 :     if (args[3]) {
         833         [ #  # ]:          0 :         if (!PyUnicode_Check(args[3])) {
         834                 :          0 :             _PyArg_BadArgument("load", "argument 'errors'", "str", args[3]);
         835                 :          0 :             goto exit;
         836                 :            :         }
         837                 :            :         Py_ssize_t errors_length;
         838                 :          0 :         errors = PyUnicode_AsUTF8AndSize(args[3], &errors_length);
         839         [ #  # ]:          0 :         if (errors == NULL) {
         840                 :          0 :             goto exit;
         841                 :            :         }
         842         [ #  # ]:          0 :         if (strlen(errors) != (size_t)errors_length) {
         843                 :          0 :             PyErr_SetString(PyExc_ValueError, "embedded null character");
         844                 :          0 :             goto exit;
         845                 :            :         }
         846         [ #  # ]:          0 :         if (!--noptargs) {
         847                 :          0 :             goto skip_optional_kwonly;
         848                 :            :         }
         849                 :            :     }
         850                 :          0 :     buffers = args[4];
         851                 :          0 : skip_optional_kwonly:
         852                 :          0 :     return_value = _pickle_load_impl(module, file, fix_imports, encoding, errors, buffers);
         853                 :            :
         854                 :          0 : exit:
         855                 :          0 :     return return_value;
         856                 :            : }
         857                 :            :
         858                 :            : PyDoc_STRVAR(_pickle_loads__doc__,
         859                 :            : "loads($module, data, /, *, fix_imports=True, encoding=\'ASCII\',\n"
         860                 :            : "      errors=\'strict\', buffers=())\n"
         861                 :            : "--\n"
         862                 :            : "\n"
         863                 :            : "Read and return an object from the given pickle data.\n"
         864                 :            : "\n"
         865                 :            : "The protocol version of the pickle is detected automatically, so no\n"
         866                 :            : "protocol argument is needed.  Bytes past the pickled object\'s\n"
         867                 :            : "representation are ignored.\n"
         868                 :            : "\n"
         869                 :            : "Optional keyword arguments are *fix_imports*, *encoding* and *errors*,\n"
         870                 :            : "which are used to control compatibility support for pickle stream\n"
         871                 :            : "generated by Python 2.  If *fix_imports* is True, pickle will try to\n"
         872                 :            : "map the old Python 2 names to the new names used in Python 3.  The\n"
         873                 :            : "*encoding* and *errors* tell pickle how to decode 8-bit string\n"
         874                 :            : "instances pickled by Python 2; these default to \'ASCII\' and \'strict\',\n"
         875                 :            : "respectively.  The *encoding* can be \'bytes\' to read these 8-bit\n"
         876                 :            : "string instances as bytes objects.");
         877                 :            :
         878                 :            : #define _PICKLE_LOADS_METHODDEF    \
         879                 :            :     {"loads", _PyCFunction_CAST(_pickle_loads), METH_FASTCALL|METH_KEYWORDS, _pickle_loads__doc__},
         880                 :            :
         881                 :            : static PyObject *
         882                 :            : _pickle_loads_impl(PyObject *module, PyObject *data, int fix_imports,
         883                 :            :                    const char *encoding, const char *errors,
         884                 :            :                    PyObject *buffers);
         885                 :            :
         886                 :            : static PyObject *
         887                 :          0 : _pickle_loads(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
         888                 :            : {
         889                 :          0 :     PyObject *return_value = NULL;
         890                 :            :     #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
         891                 :            :
         892                 :            :     #define NUM_KEYWORDS 4
         893                 :            :     static struct {
         894                 :            :         PyGC_Head _this_is_not_used;
         895                 :            :         PyObject_VAR_HEAD
         896                 :            :         PyObject *ob_item[NUM_KEYWORDS];
         897                 :            :     } _kwtuple = {
         898                 :            :         .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
         899                 :            :         .ob_item = { &_Py_ID(fix_imports), &_Py_ID(encoding), &_Py_ID(errors), &_Py_ID(buffers), },
         900                 :            :     };
         901                 :            :     #undef NUM_KEYWORDS
         902                 :            :     #define KWTUPLE (&_kwtuple.ob_base.ob_base)
         903                 :            :
         904                 :            :     #else  // !Py_BUILD_CORE
         905                 :            :     #  define KWTUPLE NULL
         906                 :            :     #endif  // !Py_BUILD_CORE
         907                 :            :
         908                 :            :     static const char * const _keywords[] = {"", "fix_imports", "encoding", "errors", "buffers", NULL};
         909                 :            :     static _PyArg_Parser _parser = {
         910                 :            :         .keywords = _keywords,
         911                 :            :         .fname = "loads",
         912                 :            :         .kwtuple = KWTUPLE,
         913                 :            :     };
         914                 :            :     #undef KWTUPLE
         915                 :            :     PyObject *argsbuf[5];
         916         [ #  # ]:          0 :     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
         917                 :            :     PyObject *data;
         918                 :          0 :     int fix_imports = 1;
         919                 :          0 :     const char *encoding = "ASCII";
         920                 :          0 :     const char *errors = "strict";
         921                 :          0 :     PyObject *buffers = NULL;
         922                 :            :
         923   [ #  #  #  #  :          0 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
                 #  #  #  # ]
         924         [ #  # ]:          0 :     if (!args) {
         925                 :          0 :         goto exit;
         926                 :            :     }
         927                 :          0 :     data = args[0];
         928         [ #  # ]:          0 :     if (!noptargs) {
         929                 :          0 :         goto skip_optional_kwonly;
         930                 :            :     }
         931         [ #  # ]:          0 :     if (args[1]) {
         932                 :          0 :         fix_imports = PyObject_IsTrue(args[1]);
         933         [ #  # ]:          0 :         if (fix_imports < 0) {
         934                 :          0 :             goto exit;
         935                 :            :         }
         936         [ #  # ]:          0 :         if (!--noptargs) {
         937                 :          0 :             goto skip_optional_kwonly;
         938                 :            :         }
         939                 :            :     }
         940         [ #  # ]:          0 :     if (args[2]) {
         941         [ #  # ]:          0 :         if (!PyUnicode_Check(args[2])) {
         942                 :          0 :             _PyArg_BadArgument("loads", "argument 'encoding'", "str", args[2]);
         943                 :          0 :             goto exit;
         944                 :            :         }
         945                 :            :         Py_ssize_t encoding_length;
         946                 :          0 :         encoding = PyUnicode_AsUTF8AndSize(args[2], &encoding_length);
         947         [ #  # ]:          0 :         if (encoding == NULL) {
         948                 :          0 :             goto exit;
         949                 :            :         }
         950         [ #  # ]:          0 :         if (strlen(encoding) != (size_t)encoding_length) {
         951                 :          0 :             PyErr_SetString(PyExc_ValueError, "embedded null character");
         952                 :          0 :             goto exit;
         953                 :            :         }
         954         [ #  # ]:          0 :         if (!--noptargs) {
         955                 :          0 :             goto skip_optional_kwonly;
         956                 :            :         }
         957                 :            :     }
         958         [ #  # ]:          0 :     if (args[3]) {
         959         [ #  # ]:          0 :         if (!PyUnicode_Check(args[3])) {
         960                 :          0 :             _PyArg_BadArgument("loads", "argument 'errors'", "str", args[3]);
         961                 :          0 :             goto exit;
         962                 :            :         }
         963                 :            :         Py_ssize_t errors_length;
         964                 :          0 :         errors = PyUnicode_AsUTF8AndSize(args[3], &errors_length);
         965         [ #  # ]:          0 :         if (errors == NULL) {
         966                 :          0 :             goto exit;
         967                 :            :         }
         968         [ #  # ]:          0 :         if (strlen(errors) != (size_t)errors_length) {
         969                 :          0 :             PyErr_SetString(PyExc_ValueError, "embedded null character");
         970                 :          0 :             goto exit;
         971                 :            :         }
         972         [ #  # ]:          0 :         if (!--noptargs) {
         973                 :          0 :             goto skip_optional_kwonly;
         974                 :            :         }
         975                 :            :     }
         976                 :          0 :     buffers = args[4];
         977                 :          0 : skip_optional_kwonly:
         978                 :          0 :     return_value = _pickle_loads_impl(module, data, fix_imports, encoding, errors, buffers);
         979                 :            :
         980                 :          0 : exit:
         981                 :          0 :     return return_value;
         982                 :            : }
         983                 :            : /*[clinic end generated code: output=730dc26938561313 input=a9049054013a1b77]*/

Generated by: LCOV version 1.14