• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*[clinic input]
2 preserve
3 [clinic start generated code]*/
4 
5 PyDoc_STRVAR(_pickle_Pickler_clear_memo__doc__,
6 "clear_memo($self, /)\n"
7 "--\n"
8 "\n"
9 "Clears the pickler\'s \"memo\".\n"
10 "\n"
11 "The memo is the data structure that remembers which objects the\n"
12 "pickler has already seen, so that shared or recursive objects are\n"
13 "pickled by reference and not by value.  This method is useful when\n"
14 "re-using picklers.");
15 
16 #define _PICKLE_PICKLER_CLEAR_MEMO_METHODDEF    \
17     {"clear_memo", (PyCFunction)_pickle_Pickler_clear_memo, METH_NOARGS, _pickle_Pickler_clear_memo__doc__},
18 
19 static PyObject *
20 _pickle_Pickler_clear_memo_impl(PicklerObject *self);
21 
22 static PyObject *
_pickle_Pickler_clear_memo(PicklerObject * self,PyObject * Py_UNUSED (ignored))23 _pickle_Pickler_clear_memo(PicklerObject *self, PyObject *Py_UNUSED(ignored))
24 {
25     return _pickle_Pickler_clear_memo_impl(self);
26 }
27 
28 PyDoc_STRVAR(_pickle_Pickler_dump__doc__,
29 "dump($self, obj, /)\n"
30 "--\n"
31 "\n"
32 "Write a pickled representation of the given object to the open file.");
33 
34 #define _PICKLE_PICKLER_DUMP_METHODDEF    \
35     {"dump", (PyCFunction)_pickle_Pickler_dump, METH_O, _pickle_Pickler_dump__doc__},
36 
37 PyDoc_STRVAR(_pickle_Pickler___sizeof____doc__,
38 "__sizeof__($self, /)\n"
39 "--\n"
40 "\n"
41 "Returns size in memory, in bytes.");
42 
43 #define _PICKLE_PICKLER___SIZEOF___METHODDEF    \
44     {"__sizeof__", (PyCFunction)_pickle_Pickler___sizeof__, METH_NOARGS, _pickle_Pickler___sizeof____doc__},
45 
46 static Py_ssize_t
47 _pickle_Pickler___sizeof___impl(PicklerObject *self);
48 
49 static PyObject *
_pickle_Pickler___sizeof__(PicklerObject * self,PyObject * Py_UNUSED (ignored))50 _pickle_Pickler___sizeof__(PicklerObject *self, PyObject *Py_UNUSED(ignored))
51 {
52     PyObject *return_value = NULL;
53     Py_ssize_t _return_value;
54 
55     _return_value = _pickle_Pickler___sizeof___impl(self);
56     if ((_return_value == -1) && PyErr_Occurred()) {
57         goto exit;
58     }
59     return_value = PyLong_FromSsize_t(_return_value);
60 
61 exit:
62     return return_value;
63 }
64 
65 PyDoc_STRVAR(_pickle_Pickler___init____doc__,
66 "Pickler(file, protocol=None, fix_imports=True)\n"
67 "--\n"
68 "\n"
69 "This takes a binary file for writing a pickle data stream.\n"
70 "\n"
71 "The optional *protocol* argument tells the pickler to use the given\n"
72 "protocol; supported protocols are 0, 1, 2, 3 and 4.  The default\n"
73 "protocol is 3; a backward-incompatible protocol designed for Python 3.\n"
74 "\n"
75 "Specifying a negative protocol version selects the highest protocol\n"
76 "version supported.  The higher the protocol used, the more recent the\n"
77 "version of Python needed to read the pickle produced.\n"
78 "\n"
79 "The *file* argument must have a write() method that accepts a single\n"
80 "bytes argument. It can thus be a file object opened for binary\n"
81 "writing, an io.BytesIO instance, or any other custom object that meets\n"
82 "this interface.\n"
83 "\n"
84 "If *fix_imports* is True and protocol is less than 3, pickle will try\n"
85 "to map the new Python 3 names to the old module names used in Python\n"
86 "2, so that the pickle data stream is readable with Python 2.");
87 
88 static int
89 _pickle_Pickler___init___impl(PicklerObject *self, PyObject *file,
90                               PyObject *protocol, int fix_imports);
91 
92 static int
_pickle_Pickler___init__(PyObject * self,PyObject * args,PyObject * kwargs)93 _pickle_Pickler___init__(PyObject *self, PyObject *args, PyObject *kwargs)
94 {
95     int return_value = -1;
96     static const char * const _keywords[] = {"file", "protocol", "fix_imports", NULL};
97     static _PyArg_Parser _parser = {"O|Op:Pickler", _keywords, 0};
98     PyObject *file;
99     PyObject *protocol = NULL;
100     int fix_imports = 1;
101 
102     if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
103         &file, &protocol, &fix_imports)) {
104         goto exit;
105     }
106     return_value = _pickle_Pickler___init___impl((PicklerObject *)self, file, protocol, fix_imports);
107 
108 exit:
109     return return_value;
110 }
111 
112 PyDoc_STRVAR(_pickle_PicklerMemoProxy_clear__doc__,
113 "clear($self, /)\n"
114 "--\n"
115 "\n"
116 "Remove all items from memo.");
117 
118 #define _PICKLE_PICKLERMEMOPROXY_CLEAR_METHODDEF    \
119     {"clear", (PyCFunction)_pickle_PicklerMemoProxy_clear, METH_NOARGS, _pickle_PicklerMemoProxy_clear__doc__},
120 
121 static PyObject *
122 _pickle_PicklerMemoProxy_clear_impl(PicklerMemoProxyObject *self);
123 
124 static PyObject *
_pickle_PicklerMemoProxy_clear(PicklerMemoProxyObject * self,PyObject * Py_UNUSED (ignored))125 _pickle_PicklerMemoProxy_clear(PicklerMemoProxyObject *self, PyObject *Py_UNUSED(ignored))
126 {
127     return _pickle_PicklerMemoProxy_clear_impl(self);
128 }
129 
130 PyDoc_STRVAR(_pickle_PicklerMemoProxy_copy__doc__,
131 "copy($self, /)\n"
132 "--\n"
133 "\n"
134 "Copy the memo to a new object.");
135 
136 #define _PICKLE_PICKLERMEMOPROXY_COPY_METHODDEF    \
137     {"copy", (PyCFunction)_pickle_PicklerMemoProxy_copy, METH_NOARGS, _pickle_PicklerMemoProxy_copy__doc__},
138 
139 static PyObject *
140 _pickle_PicklerMemoProxy_copy_impl(PicklerMemoProxyObject *self);
141 
142 static PyObject *
_pickle_PicklerMemoProxy_copy(PicklerMemoProxyObject * self,PyObject * Py_UNUSED (ignored))143 _pickle_PicklerMemoProxy_copy(PicklerMemoProxyObject *self, PyObject *Py_UNUSED(ignored))
144 {
145     return _pickle_PicklerMemoProxy_copy_impl(self);
146 }
147 
148 PyDoc_STRVAR(_pickle_PicklerMemoProxy___reduce____doc__,
149 "__reduce__($self, /)\n"
150 "--\n"
151 "\n"
152 "Implement pickle support.");
153 
154 #define _PICKLE_PICKLERMEMOPROXY___REDUCE___METHODDEF    \
155     {"__reduce__", (PyCFunction)_pickle_PicklerMemoProxy___reduce__, METH_NOARGS, _pickle_PicklerMemoProxy___reduce____doc__},
156 
157 static PyObject *
158 _pickle_PicklerMemoProxy___reduce___impl(PicklerMemoProxyObject *self);
159 
160 static PyObject *
_pickle_PicklerMemoProxy___reduce__(PicklerMemoProxyObject * self,PyObject * Py_UNUSED (ignored))161 _pickle_PicklerMemoProxy___reduce__(PicklerMemoProxyObject *self, PyObject *Py_UNUSED(ignored))
162 {
163     return _pickle_PicklerMemoProxy___reduce___impl(self);
164 }
165 
166 PyDoc_STRVAR(_pickle_Unpickler_load__doc__,
167 "load($self, /)\n"
168 "--\n"
169 "\n"
170 "Load a pickle.\n"
171 "\n"
172 "Read a pickled object representation from the open file object given\n"
173 "in the constructor, and return the reconstituted object hierarchy\n"
174 "specified therein.");
175 
176 #define _PICKLE_UNPICKLER_LOAD_METHODDEF    \
177     {"load", (PyCFunction)_pickle_Unpickler_load, METH_NOARGS, _pickle_Unpickler_load__doc__},
178 
179 static PyObject *
180 _pickle_Unpickler_load_impl(UnpicklerObject *self);
181 
182 static PyObject *
_pickle_Unpickler_load(UnpicklerObject * self,PyObject * Py_UNUSED (ignored))183 _pickle_Unpickler_load(UnpicklerObject *self, PyObject *Py_UNUSED(ignored))
184 {
185     return _pickle_Unpickler_load_impl(self);
186 }
187 
188 PyDoc_STRVAR(_pickle_Unpickler_find_class__doc__,
189 "find_class($self, module_name, global_name, /)\n"
190 "--\n"
191 "\n"
192 "Return an object from a specified module.\n"
193 "\n"
194 "If necessary, the module will be imported. Subclasses may override\n"
195 "this method (e.g. to restrict unpickling of arbitrary classes and\n"
196 "functions).\n"
197 "\n"
198 "This method is called whenever a class or a function object is\n"
199 "needed.  Both arguments passed are str objects.");
200 
201 #define _PICKLE_UNPICKLER_FIND_CLASS_METHODDEF    \
202     {"find_class", (PyCFunction)_pickle_Unpickler_find_class, METH_FASTCALL, _pickle_Unpickler_find_class__doc__},
203 
204 static PyObject *
205 _pickle_Unpickler_find_class_impl(UnpicklerObject *self,
206                                   PyObject *module_name,
207                                   PyObject *global_name);
208 
209 static PyObject *
_pickle_Unpickler_find_class(UnpicklerObject * self,PyObject * const * args,Py_ssize_t nargs)210 _pickle_Unpickler_find_class(UnpicklerObject *self, PyObject *const *args, Py_ssize_t nargs)
211 {
212     PyObject *return_value = NULL;
213     PyObject *module_name;
214     PyObject *global_name;
215 
216     if (!_PyArg_UnpackStack(args, nargs, "find_class",
217         2, 2,
218         &module_name, &global_name)) {
219         goto exit;
220     }
221     return_value = _pickle_Unpickler_find_class_impl(self, module_name, global_name);
222 
223 exit:
224     return return_value;
225 }
226 
227 PyDoc_STRVAR(_pickle_Unpickler___sizeof____doc__,
228 "__sizeof__($self, /)\n"
229 "--\n"
230 "\n"
231 "Returns size in memory, in bytes.");
232 
233 #define _PICKLE_UNPICKLER___SIZEOF___METHODDEF    \
234     {"__sizeof__", (PyCFunction)_pickle_Unpickler___sizeof__, METH_NOARGS, _pickle_Unpickler___sizeof____doc__},
235 
236 static Py_ssize_t
237 _pickle_Unpickler___sizeof___impl(UnpicklerObject *self);
238 
239 static PyObject *
_pickle_Unpickler___sizeof__(UnpicklerObject * self,PyObject * Py_UNUSED (ignored))240 _pickle_Unpickler___sizeof__(UnpicklerObject *self, PyObject *Py_UNUSED(ignored))
241 {
242     PyObject *return_value = NULL;
243     Py_ssize_t _return_value;
244 
245     _return_value = _pickle_Unpickler___sizeof___impl(self);
246     if ((_return_value == -1) && PyErr_Occurred()) {
247         goto exit;
248     }
249     return_value = PyLong_FromSsize_t(_return_value);
250 
251 exit:
252     return return_value;
253 }
254 
255 PyDoc_STRVAR(_pickle_Unpickler___init____doc__,
256 "Unpickler(file, *, fix_imports=True, encoding=\'ASCII\', errors=\'strict\')\n"
257 "--\n"
258 "\n"
259 "This takes a binary file for reading a pickle data stream.\n"
260 "\n"
261 "The protocol version of the pickle is detected automatically, so no\n"
262 "protocol argument is needed.  Bytes past the pickled object\'s\n"
263 "representation are ignored.\n"
264 "\n"
265 "The argument *file* must have two methods, a read() method that takes\n"
266 "an integer argument, and a readline() method that requires no\n"
267 "arguments.  Both methods should return bytes.  Thus *file* can be a\n"
268 "binary file object opened for reading, an io.BytesIO object, or any\n"
269 "other custom object that meets this interface.\n"
270 "\n"
271 "Optional keyword arguments are *fix_imports*, *encoding* and *errors*,\n"
272 "which are used to control compatibility support for pickle stream\n"
273 "generated by Python 2.  If *fix_imports* is True, pickle will try to\n"
274 "map the old Python 2 names to the new names used in Python 3.  The\n"
275 "*encoding* and *errors* tell pickle how to decode 8-bit string\n"
276 "instances pickled by Python 2; these default to \'ASCII\' and \'strict\',\n"
277 "respectively.  The *encoding* can be \'bytes\' to read these 8-bit\n"
278 "string instances as bytes objects.");
279 
280 static int
281 _pickle_Unpickler___init___impl(UnpicklerObject *self, PyObject *file,
282                                 int fix_imports, const char *encoding,
283                                 const char *errors);
284 
285 static int
_pickle_Unpickler___init__(PyObject * self,PyObject * args,PyObject * kwargs)286 _pickle_Unpickler___init__(PyObject *self, PyObject *args, PyObject *kwargs)
287 {
288     int return_value = -1;
289     static const char * const _keywords[] = {"file", "fix_imports", "encoding", "errors", NULL};
290     static _PyArg_Parser _parser = {"O|$pss:Unpickler", _keywords, 0};
291     PyObject *file;
292     int fix_imports = 1;
293     const char *encoding = "ASCII";
294     const char *errors = "strict";
295 
296     if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
297         &file, &fix_imports, &encoding, &errors)) {
298         goto exit;
299     }
300     return_value = _pickle_Unpickler___init___impl((UnpicklerObject *)self, file, fix_imports, encoding, errors);
301 
302 exit:
303     return return_value;
304 }
305 
306 PyDoc_STRVAR(_pickle_UnpicklerMemoProxy_clear__doc__,
307 "clear($self, /)\n"
308 "--\n"
309 "\n"
310 "Remove all items from memo.");
311 
312 #define _PICKLE_UNPICKLERMEMOPROXY_CLEAR_METHODDEF    \
313     {"clear", (PyCFunction)_pickle_UnpicklerMemoProxy_clear, METH_NOARGS, _pickle_UnpicklerMemoProxy_clear__doc__},
314 
315 static PyObject *
316 _pickle_UnpicklerMemoProxy_clear_impl(UnpicklerMemoProxyObject *self);
317 
318 static PyObject *
_pickle_UnpicklerMemoProxy_clear(UnpicklerMemoProxyObject * self,PyObject * Py_UNUSED (ignored))319 _pickle_UnpicklerMemoProxy_clear(UnpicklerMemoProxyObject *self, PyObject *Py_UNUSED(ignored))
320 {
321     return _pickle_UnpicklerMemoProxy_clear_impl(self);
322 }
323 
324 PyDoc_STRVAR(_pickle_UnpicklerMemoProxy_copy__doc__,
325 "copy($self, /)\n"
326 "--\n"
327 "\n"
328 "Copy the memo to a new object.");
329 
330 #define _PICKLE_UNPICKLERMEMOPROXY_COPY_METHODDEF    \
331     {"copy", (PyCFunction)_pickle_UnpicklerMemoProxy_copy, METH_NOARGS, _pickle_UnpicklerMemoProxy_copy__doc__},
332 
333 static PyObject *
334 _pickle_UnpicklerMemoProxy_copy_impl(UnpicklerMemoProxyObject *self);
335 
336 static PyObject *
_pickle_UnpicklerMemoProxy_copy(UnpicklerMemoProxyObject * self,PyObject * Py_UNUSED (ignored))337 _pickle_UnpicklerMemoProxy_copy(UnpicklerMemoProxyObject *self, PyObject *Py_UNUSED(ignored))
338 {
339     return _pickle_UnpicklerMemoProxy_copy_impl(self);
340 }
341 
342 PyDoc_STRVAR(_pickle_UnpicklerMemoProxy___reduce____doc__,
343 "__reduce__($self, /)\n"
344 "--\n"
345 "\n"
346 "Implement pickling support.");
347 
348 #define _PICKLE_UNPICKLERMEMOPROXY___REDUCE___METHODDEF    \
349     {"__reduce__", (PyCFunction)_pickle_UnpicklerMemoProxy___reduce__, METH_NOARGS, _pickle_UnpicklerMemoProxy___reduce____doc__},
350 
351 static PyObject *
352 _pickle_UnpicklerMemoProxy___reduce___impl(UnpicklerMemoProxyObject *self);
353 
354 static PyObject *
_pickle_UnpicklerMemoProxy___reduce__(UnpicklerMemoProxyObject * self,PyObject * Py_UNUSED (ignored))355 _pickle_UnpicklerMemoProxy___reduce__(UnpicklerMemoProxyObject *self, PyObject *Py_UNUSED(ignored))
356 {
357     return _pickle_UnpicklerMemoProxy___reduce___impl(self);
358 }
359 
360 PyDoc_STRVAR(_pickle_dump__doc__,
361 "dump($module, /, obj, file, protocol=None, *, fix_imports=True)\n"
362 "--\n"
363 "\n"
364 "Write a pickled representation of obj to the open file object file.\n"
365 "\n"
366 "This is equivalent to ``Pickler(file, protocol).dump(obj)``, but may\n"
367 "be more efficient.\n"
368 "\n"
369 "The optional *protocol* argument tells the pickler to use the given\n"
370 "protocol supported protocols are 0, 1, 2, 3 and 4.  The default\n"
371 "protocol is 3; a backward-incompatible protocol designed for Python 3.\n"
372 "\n"
373 "Specifying a negative protocol version selects the highest protocol\n"
374 "version supported.  The higher the protocol used, the more recent the\n"
375 "version of Python needed to read the pickle produced.\n"
376 "\n"
377 "The *file* argument must have a write() method that accepts a single\n"
378 "bytes argument.  It can thus be a file object opened for binary\n"
379 "writing, an io.BytesIO instance, or any other custom object that meets\n"
380 "this interface.\n"
381 "\n"
382 "If *fix_imports* is True and protocol is less than 3, pickle will try\n"
383 "to map the new Python 3 names to the old module names used in Python\n"
384 "2, so that the pickle data stream is readable with Python 2.");
385 
386 #define _PICKLE_DUMP_METHODDEF    \
387     {"dump", (PyCFunction)_pickle_dump, METH_FASTCALL|METH_KEYWORDS, _pickle_dump__doc__},
388 
389 static PyObject *
390 _pickle_dump_impl(PyObject *module, PyObject *obj, PyObject *file,
391                   PyObject *protocol, int fix_imports);
392 
393 static PyObject *
_pickle_dump(PyObject * module,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)394 _pickle_dump(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
395 {
396     PyObject *return_value = NULL;
397     static const char * const _keywords[] = {"obj", "file", "protocol", "fix_imports", NULL};
398     static _PyArg_Parser _parser = {"OO|O$p:dump", _keywords, 0};
399     PyObject *obj;
400     PyObject *file;
401     PyObject *protocol = NULL;
402     int fix_imports = 1;
403 
404     if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
405         &obj, &file, &protocol, &fix_imports)) {
406         goto exit;
407     }
408     return_value = _pickle_dump_impl(module, obj, file, protocol, fix_imports);
409 
410 exit:
411     return return_value;
412 }
413 
414 PyDoc_STRVAR(_pickle_dumps__doc__,
415 "dumps($module, /, obj, protocol=None, *, fix_imports=True)\n"
416 "--\n"
417 "\n"
418 "Return the pickled representation of the object as a bytes object.\n"
419 "\n"
420 "The optional *protocol* argument tells the pickler to use the given\n"
421 "protocol; supported protocols are 0, 1, 2, 3 and 4.  The default\n"
422 "protocol is 3; a backward-incompatible protocol designed for Python 3.\n"
423 "\n"
424 "Specifying a negative protocol version selects the highest protocol\n"
425 "version supported.  The higher the protocol used, the more recent the\n"
426 "version of Python needed to read the pickle produced.\n"
427 "\n"
428 "If *fix_imports* is True and *protocol* is less than 3, pickle will\n"
429 "try to map the new Python 3 names to the old module names used in\n"
430 "Python 2, so that the pickle data stream is readable with Python 2.");
431 
432 #define _PICKLE_DUMPS_METHODDEF    \
433     {"dumps", (PyCFunction)_pickle_dumps, METH_FASTCALL|METH_KEYWORDS, _pickle_dumps__doc__},
434 
435 static PyObject *
436 _pickle_dumps_impl(PyObject *module, PyObject *obj, PyObject *protocol,
437                    int fix_imports);
438 
439 static PyObject *
_pickle_dumps(PyObject * module,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)440 _pickle_dumps(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
441 {
442     PyObject *return_value = NULL;
443     static const char * const _keywords[] = {"obj", "protocol", "fix_imports", NULL};
444     static _PyArg_Parser _parser = {"O|O$p:dumps", _keywords, 0};
445     PyObject *obj;
446     PyObject *protocol = NULL;
447     int fix_imports = 1;
448 
449     if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
450         &obj, &protocol, &fix_imports)) {
451         goto exit;
452     }
453     return_value = _pickle_dumps_impl(module, obj, protocol, fix_imports);
454 
455 exit:
456     return return_value;
457 }
458 
459 PyDoc_STRVAR(_pickle_load__doc__,
460 "load($module, /, file, *, fix_imports=True, encoding=\'ASCII\',\n"
461 "     errors=\'strict\')\n"
462 "--\n"
463 "\n"
464 "Read and return an object from the pickle data stored in a file.\n"
465 "\n"
466 "This is equivalent to ``Unpickler(file).load()``, but may be more\n"
467 "efficient.\n"
468 "\n"
469 "The protocol version of the pickle is detected automatically, so no\n"
470 "protocol argument is needed.  Bytes past the pickled object\'s\n"
471 "representation are ignored.\n"
472 "\n"
473 "The argument *file* must have two methods, a read() method that takes\n"
474 "an integer argument, and a readline() method that requires no\n"
475 "arguments.  Both methods should return bytes.  Thus *file* can be a\n"
476 "binary file object opened for reading, an io.BytesIO object, or any\n"
477 "other custom object that meets this interface.\n"
478 "\n"
479 "Optional keyword arguments are *fix_imports*, *encoding* and *errors*,\n"
480 "which are used to control compatibility support for pickle stream\n"
481 "generated by Python 2.  If *fix_imports* is True, pickle will try to\n"
482 "map the old Python 2 names to the new names used in Python 3.  The\n"
483 "*encoding* and *errors* tell pickle how to decode 8-bit string\n"
484 "instances pickled by Python 2; these default to \'ASCII\' and \'strict\',\n"
485 "respectively.  The *encoding* can be \'bytes\' to read these 8-bit\n"
486 "string instances as bytes objects.");
487 
488 #define _PICKLE_LOAD_METHODDEF    \
489     {"load", (PyCFunction)_pickle_load, METH_FASTCALL|METH_KEYWORDS, _pickle_load__doc__},
490 
491 static PyObject *
492 _pickle_load_impl(PyObject *module, PyObject *file, int fix_imports,
493                   const char *encoding, const char *errors);
494 
495 static PyObject *
_pickle_load(PyObject * module,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)496 _pickle_load(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
497 {
498     PyObject *return_value = NULL;
499     static const char * const _keywords[] = {"file", "fix_imports", "encoding", "errors", NULL};
500     static _PyArg_Parser _parser = {"O|$pss:load", _keywords, 0};
501     PyObject *file;
502     int fix_imports = 1;
503     const char *encoding = "ASCII";
504     const char *errors = "strict";
505 
506     if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
507         &file, &fix_imports, &encoding, &errors)) {
508         goto exit;
509     }
510     return_value = _pickle_load_impl(module, file, fix_imports, encoding, errors);
511 
512 exit:
513     return return_value;
514 }
515 
516 PyDoc_STRVAR(_pickle_loads__doc__,
517 "loads($module, /, data, *, fix_imports=True, encoding=\'ASCII\',\n"
518 "      errors=\'strict\')\n"
519 "--\n"
520 "\n"
521 "Read and return an object from the given pickle data.\n"
522 "\n"
523 "The protocol version of the pickle is detected automatically, so no\n"
524 "protocol argument is needed.  Bytes past the pickled object\'s\n"
525 "representation are ignored.\n"
526 "\n"
527 "Optional keyword arguments are *fix_imports*, *encoding* and *errors*,\n"
528 "which are used to control compatibility support for pickle stream\n"
529 "generated by Python 2.  If *fix_imports* is True, pickle will try to\n"
530 "map the old Python 2 names to the new names used in Python 3.  The\n"
531 "*encoding* and *errors* tell pickle how to decode 8-bit string\n"
532 "instances pickled by Python 2; these default to \'ASCII\' and \'strict\',\n"
533 "respectively.  The *encoding* can be \'bytes\' to read these 8-bit\n"
534 "string instances as bytes objects.");
535 
536 #define _PICKLE_LOADS_METHODDEF    \
537     {"loads", (PyCFunction)_pickle_loads, METH_FASTCALL|METH_KEYWORDS, _pickle_loads__doc__},
538 
539 static PyObject *
540 _pickle_loads_impl(PyObject *module, PyObject *data, int fix_imports,
541                    const char *encoding, const char *errors);
542 
543 static PyObject *
_pickle_loads(PyObject * module,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)544 _pickle_loads(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
545 {
546     PyObject *return_value = NULL;
547     static const char * const _keywords[] = {"data", "fix_imports", "encoding", "errors", NULL};
548     static _PyArg_Parser _parser = {"O|$pss:loads", _keywords, 0};
549     PyObject *data;
550     int fix_imports = 1;
551     const char *encoding = "ASCII";
552     const char *errors = "strict";
553 
554     if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
555         &data, &fix_imports, &encoding, &errors)) {
556         goto exit;
557     }
558     return_value = _pickle_loads_impl(module, data, fix_imports, encoding, errors);
559 
560 exit:
561     return return_value;
562 }
563 /*[clinic end generated code: output=e995dd494045d876 input=a9049054013a1b77]*/
564