blob: c0c54d20234e0bde09f510bf9df1ddfc512a30fe [file] [log] [blame]
Serhiy Storchaka3c1f0f12014-01-27 10:34:22 +02001/*[clinic input]
2preserve
3[clinic start generated code]*/
4
5PyDoc_STRVAR(_pickle_Pickler_clear_memo__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -08006"clear_memo($self, /)\n"
7"--\n"
8"\n"
Serhiy Storchaka3c1f0f12014-01-27 10:34:22 +02009"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
19static PyObject *
20_pickle_Pickler_clear_memo_impl(PicklerObject *self);
21
22static PyObject *
23_pickle_Pickler_clear_memo(PicklerObject *self, PyObject *Py_UNUSED(ignored))
24{
25 return _pickle_Pickler_clear_memo_impl(self);
26}
27
28PyDoc_STRVAR(_pickle_Pickler_dump__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -080029"dump($self, obj, /)\n"
30"--\n"
31"\n"
Serhiy Storchaka3c1f0f12014-01-27 10:34:22 +020032"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
Serhiy Storchaka5bbd2312014-12-16 19:39:08 +020037PyDoc_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
46static Py_ssize_t
47_pickle_Pickler___sizeof___impl(PicklerObject *self);
48
49static PyObject *
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 return_value = PyLong_FromSsize_t(_return_value);
59
60exit:
61 return return_value;
62}
63
Serhiy Storchaka3c1f0f12014-01-27 10:34:22 +020064PyDoc_STRVAR(_pickle_Pickler___init____doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -080065"Pickler(file, protocol=None, fix_imports=True)\n"
66"--\n"
67"\n"
Serhiy Storchaka3c1f0f12014-01-27 10:34:22 +020068"This takes a binary file for writing a pickle data stream.\n"
69"\n"
70"The optional *protocol* argument tells the pickler to use the given\n"
71"protocol; supported protocols are 0, 1, 2, 3 and 4. The default\n"
72"protocol is 3; a backward-incompatible protocol designed for Python 3.\n"
73"\n"
74"Specifying a negative protocol version selects the highest protocol\n"
75"version supported. The higher the protocol used, the more recent the\n"
76"version of Python needed to read the pickle produced.\n"
77"\n"
78"The *file* argument must have a write() method that accepts a single\n"
79"bytes argument. It can thus be a file object opened for binary\n"
Martin Panter7462b6492015-11-02 03:37:02 +000080"writing, an io.BytesIO instance, or any other custom object that meets\n"
Serhiy Storchaka3c1f0f12014-01-27 10:34:22 +020081"this interface.\n"
82"\n"
83"If *fix_imports* is True and protocol is less than 3, pickle will try\n"
84"to map the new Python 3 names to the old module names used in Python\n"
85"2, so that the pickle data stream is readable with Python 2.");
86
87static int
88_pickle_Pickler___init___impl(PicklerObject *self, PyObject *file, PyObject *protocol, int fix_imports);
89
90static int
91_pickle_Pickler___init__(PyObject *self, PyObject *args, PyObject *kwargs)
92{
93 int return_value = -1;
94 static char *_keywords[] = {"file", "protocol", "fix_imports", NULL};
95 PyObject *file;
96 PyObject *protocol = NULL;
97 int fix_imports = 1;
98
99 if (!PyArg_ParseTupleAndKeywords(args, kwargs,
100 "O|Op:Pickler", _keywords,
101 &file, &protocol, &fix_imports))
102 goto exit;
103 return_value = _pickle_Pickler___init___impl((PicklerObject *)self, file, protocol, fix_imports);
104
105exit:
106 return return_value;
107}
108
109PyDoc_STRVAR(_pickle_PicklerMemoProxy_clear__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800110"clear($self, /)\n"
111"--\n"
112"\n"
Serhiy Storchaka3c1f0f12014-01-27 10:34:22 +0200113"Remove all items from memo.");
114
115#define _PICKLE_PICKLERMEMOPROXY_CLEAR_METHODDEF \
116 {"clear", (PyCFunction)_pickle_PicklerMemoProxy_clear, METH_NOARGS, _pickle_PicklerMemoProxy_clear__doc__},
117
118static PyObject *
119_pickle_PicklerMemoProxy_clear_impl(PicklerMemoProxyObject *self);
120
121static PyObject *
122_pickle_PicklerMemoProxy_clear(PicklerMemoProxyObject *self, PyObject *Py_UNUSED(ignored))
123{
124 return _pickle_PicklerMemoProxy_clear_impl(self);
125}
126
127PyDoc_STRVAR(_pickle_PicklerMemoProxy_copy__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800128"copy($self, /)\n"
129"--\n"
130"\n"
Serhiy Storchaka3c1f0f12014-01-27 10:34:22 +0200131"Copy the memo to a new object.");
132
133#define _PICKLE_PICKLERMEMOPROXY_COPY_METHODDEF \
134 {"copy", (PyCFunction)_pickle_PicklerMemoProxy_copy, METH_NOARGS, _pickle_PicklerMemoProxy_copy__doc__},
135
136static PyObject *
137_pickle_PicklerMemoProxy_copy_impl(PicklerMemoProxyObject *self);
138
139static PyObject *
140_pickle_PicklerMemoProxy_copy(PicklerMemoProxyObject *self, PyObject *Py_UNUSED(ignored))
141{
142 return _pickle_PicklerMemoProxy_copy_impl(self);
143}
144
145PyDoc_STRVAR(_pickle_PicklerMemoProxy___reduce____doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800146"__reduce__($self, /)\n"
147"--\n"
148"\n"
Serhiy Storchaka3c1f0f12014-01-27 10:34:22 +0200149"Implement pickle support.");
150
151#define _PICKLE_PICKLERMEMOPROXY___REDUCE___METHODDEF \
152 {"__reduce__", (PyCFunction)_pickle_PicklerMemoProxy___reduce__, METH_NOARGS, _pickle_PicklerMemoProxy___reduce____doc__},
153
154static PyObject *
155_pickle_PicklerMemoProxy___reduce___impl(PicklerMemoProxyObject *self);
156
157static PyObject *
158_pickle_PicklerMemoProxy___reduce__(PicklerMemoProxyObject *self, PyObject *Py_UNUSED(ignored))
159{
160 return _pickle_PicklerMemoProxy___reduce___impl(self);
161}
162
163PyDoc_STRVAR(_pickle_Unpickler_load__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800164"load($self, /)\n"
165"--\n"
166"\n"
Serhiy Storchaka3c1f0f12014-01-27 10:34:22 +0200167"Load a pickle.\n"
168"\n"
169"Read a pickled object representation from the open file object given\n"
170"in the constructor, and return the reconstituted object hierarchy\n"
171"specified therein.");
172
173#define _PICKLE_UNPICKLER_LOAD_METHODDEF \
174 {"load", (PyCFunction)_pickle_Unpickler_load, METH_NOARGS, _pickle_Unpickler_load__doc__},
175
176static PyObject *
177_pickle_Unpickler_load_impl(UnpicklerObject *self);
178
179static PyObject *
180_pickle_Unpickler_load(UnpicklerObject *self, PyObject *Py_UNUSED(ignored))
181{
182 return _pickle_Unpickler_load_impl(self);
183}
184
185PyDoc_STRVAR(_pickle_Unpickler_find_class__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800186"find_class($self, module_name, global_name, /)\n"
187"--\n"
188"\n"
Serhiy Storchaka3c1f0f12014-01-27 10:34:22 +0200189"Return an object from a specified module.\n"
190"\n"
191"If necessary, the module will be imported. Subclasses may override\n"
192"this method (e.g. to restrict unpickling of arbitrary classes and\n"
193"functions).\n"
194"\n"
195"This method is called whenever a class or a function object is\n"
196"needed. Both arguments passed are str objects.");
197
198#define _PICKLE_UNPICKLER_FIND_CLASS_METHODDEF \
199 {"find_class", (PyCFunction)_pickle_Unpickler_find_class, METH_VARARGS, _pickle_Unpickler_find_class__doc__},
200
201static PyObject *
202_pickle_Unpickler_find_class_impl(UnpicklerObject *self, PyObject *module_name, PyObject *global_name);
203
204static PyObject *
205_pickle_Unpickler_find_class(UnpicklerObject *self, PyObject *args)
206{
207 PyObject *return_value = NULL;
208 PyObject *module_name;
209 PyObject *global_name;
210
211 if (!PyArg_UnpackTuple(args, "find_class",
212 2, 2,
213 &module_name, &global_name))
214 goto exit;
215 return_value = _pickle_Unpickler_find_class_impl(self, module_name, global_name);
216
217exit:
218 return return_value;
219}
220
Serhiy Storchaka5bbd2312014-12-16 19:39:08 +0200221PyDoc_STRVAR(_pickle_Unpickler___sizeof____doc__,
222"__sizeof__($self, /)\n"
223"--\n"
224"\n"
225"Returns size in memory, in bytes.");
226
227#define _PICKLE_UNPICKLER___SIZEOF___METHODDEF \
228 {"__sizeof__", (PyCFunction)_pickle_Unpickler___sizeof__, METH_NOARGS, _pickle_Unpickler___sizeof____doc__},
229
230static Py_ssize_t
231_pickle_Unpickler___sizeof___impl(UnpicklerObject *self);
232
233static PyObject *
234_pickle_Unpickler___sizeof__(UnpicklerObject *self, PyObject *Py_UNUSED(ignored))
235{
236 PyObject *return_value = NULL;
237 Py_ssize_t _return_value;
238
239 _return_value = _pickle_Unpickler___sizeof___impl(self);
240 if ((_return_value == -1) && PyErr_Occurred())
241 goto exit;
242 return_value = PyLong_FromSsize_t(_return_value);
243
244exit:
245 return return_value;
246}
247
Serhiy Storchaka3c1f0f12014-01-27 10:34:22 +0200248PyDoc_STRVAR(_pickle_Unpickler___init____doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800249"Unpickler(file, *, fix_imports=True, encoding=\'ASCII\', errors=\'strict\')\n"
250"--\n"
251"\n"
Serhiy Storchaka3c1f0f12014-01-27 10:34:22 +0200252"This takes a binary file for reading a pickle data stream.\n"
253"\n"
254"The protocol version of the pickle is detected automatically, so no\n"
255"protocol argument is needed. Bytes past the pickled object\'s\n"
256"representation are ignored.\n"
257"\n"
258"The argument *file* must have two methods, a read() method that takes\n"
259"an integer argument, and a readline() method that requires no\n"
260"arguments. Both methods should return bytes. Thus *file* can be a\n"
Martin Panter7462b6492015-11-02 03:37:02 +0000261"binary file object opened for reading, an io.BytesIO object, or any\n"
Serhiy Storchaka3c1f0f12014-01-27 10:34:22 +0200262"other custom object that meets this interface.\n"
263"\n"
264"Optional keyword arguments are *fix_imports*, *encoding* and *errors*,\n"
265"which are used to control compatiblity support for pickle stream\n"
266"generated by Python 2. If *fix_imports* is True, pickle will try to\n"
267"map the old Python 2 names to the new names used in Python 3. The\n"
268"*encoding* and *errors* tell pickle how to decode 8-bit string\n"
269"instances pickled by Python 2; these default to \'ASCII\' and \'strict\',\n"
270"respectively. The *encoding* can be \'bytes\' to read these 8-bit\n"
271"string instances as bytes objects.");
272
273static int
274_pickle_Unpickler___init___impl(UnpicklerObject *self, PyObject *file, int fix_imports, const char *encoding, const char *errors);
275
276static int
277_pickle_Unpickler___init__(PyObject *self, PyObject *args, PyObject *kwargs)
278{
279 int return_value = -1;
280 static char *_keywords[] = {"file", "fix_imports", "encoding", "errors", NULL};
281 PyObject *file;
282 int fix_imports = 1;
283 const char *encoding = "ASCII";
284 const char *errors = "strict";
285
286 if (!PyArg_ParseTupleAndKeywords(args, kwargs,
287 "O|$pss:Unpickler", _keywords,
288 &file, &fix_imports, &encoding, &errors))
289 goto exit;
290 return_value = _pickle_Unpickler___init___impl((UnpicklerObject *)self, file, fix_imports, encoding, errors);
291
292exit:
293 return return_value;
294}
295
296PyDoc_STRVAR(_pickle_UnpicklerMemoProxy_clear__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800297"clear($self, /)\n"
298"--\n"
299"\n"
Serhiy Storchaka3c1f0f12014-01-27 10:34:22 +0200300"Remove all items from memo.");
301
302#define _PICKLE_UNPICKLERMEMOPROXY_CLEAR_METHODDEF \
303 {"clear", (PyCFunction)_pickle_UnpicklerMemoProxy_clear, METH_NOARGS, _pickle_UnpicklerMemoProxy_clear__doc__},
304
305static PyObject *
306_pickle_UnpicklerMemoProxy_clear_impl(UnpicklerMemoProxyObject *self);
307
308static PyObject *
309_pickle_UnpicklerMemoProxy_clear(UnpicklerMemoProxyObject *self, PyObject *Py_UNUSED(ignored))
310{
311 return _pickle_UnpicklerMemoProxy_clear_impl(self);
312}
313
314PyDoc_STRVAR(_pickle_UnpicklerMemoProxy_copy__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800315"copy($self, /)\n"
316"--\n"
317"\n"
Serhiy Storchaka3c1f0f12014-01-27 10:34:22 +0200318"Copy the memo to a new object.");
319
320#define _PICKLE_UNPICKLERMEMOPROXY_COPY_METHODDEF \
321 {"copy", (PyCFunction)_pickle_UnpicklerMemoProxy_copy, METH_NOARGS, _pickle_UnpicklerMemoProxy_copy__doc__},
322
323static PyObject *
324_pickle_UnpicklerMemoProxy_copy_impl(UnpicklerMemoProxyObject *self);
325
326static PyObject *
327_pickle_UnpicklerMemoProxy_copy(UnpicklerMemoProxyObject *self, PyObject *Py_UNUSED(ignored))
328{
329 return _pickle_UnpicklerMemoProxy_copy_impl(self);
330}
331
332PyDoc_STRVAR(_pickle_UnpicklerMemoProxy___reduce____doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800333"__reduce__($self, /)\n"
334"--\n"
335"\n"
Serhiy Storchaka3c1f0f12014-01-27 10:34:22 +0200336"Implement pickling support.");
337
338#define _PICKLE_UNPICKLERMEMOPROXY___REDUCE___METHODDEF \
339 {"__reduce__", (PyCFunction)_pickle_UnpicklerMemoProxy___reduce__, METH_NOARGS, _pickle_UnpicklerMemoProxy___reduce____doc__},
340
341static PyObject *
342_pickle_UnpicklerMemoProxy___reduce___impl(UnpicklerMemoProxyObject *self);
343
344static PyObject *
345_pickle_UnpicklerMemoProxy___reduce__(UnpicklerMemoProxyObject *self, PyObject *Py_UNUSED(ignored))
346{
347 return _pickle_UnpicklerMemoProxy___reduce___impl(self);
348}
349
350PyDoc_STRVAR(_pickle_dump__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800351"dump($module, /, obj, file, protocol=None, *, fix_imports=True)\n"
352"--\n"
353"\n"
Serhiy Storchaka3c1f0f12014-01-27 10:34:22 +0200354"Write a pickled representation of obj to the open file object file.\n"
355"\n"
356"This is equivalent to ``Pickler(file, protocol).dump(obj)``, but may\n"
357"be more efficient.\n"
358"\n"
359"The optional *protocol* argument tells the pickler to use the given\n"
360"protocol supported protocols are 0, 1, 2, 3 and 4. The default\n"
361"protocol is 3; a backward-incompatible protocol designed for Python 3.\n"
362"\n"
363"Specifying a negative protocol version selects the highest protocol\n"
364"version supported. The higher the protocol used, the more recent the\n"
365"version of Python needed to read the pickle produced.\n"
366"\n"
367"The *file* argument must have a write() method that accepts a single\n"
368"bytes argument. It can thus be a file object opened for binary\n"
Martin Panter7462b6492015-11-02 03:37:02 +0000369"writing, an io.BytesIO instance, or any other custom object that meets\n"
Serhiy Storchaka3c1f0f12014-01-27 10:34:22 +0200370"this interface.\n"
371"\n"
372"If *fix_imports* is True and protocol is less than 3, pickle will try\n"
373"to map the new Python 3 names to the old module names used in Python\n"
374"2, so that the pickle data stream is readable with Python 2.");
375
376#define _PICKLE_DUMP_METHODDEF \
377 {"dump", (PyCFunction)_pickle_dump, METH_VARARGS|METH_KEYWORDS, _pickle_dump__doc__},
378
379static PyObject *
380_pickle_dump_impl(PyModuleDef *module, PyObject *obj, PyObject *file, PyObject *protocol, int fix_imports);
381
382static PyObject *
383_pickle_dump(PyModuleDef *module, PyObject *args, PyObject *kwargs)
384{
385 PyObject *return_value = NULL;
386 static char *_keywords[] = {"obj", "file", "protocol", "fix_imports", NULL};
387 PyObject *obj;
388 PyObject *file;
389 PyObject *protocol = NULL;
390 int fix_imports = 1;
391
392 if (!PyArg_ParseTupleAndKeywords(args, kwargs,
393 "OO|O$p:dump", _keywords,
394 &obj, &file, &protocol, &fix_imports))
395 goto exit;
396 return_value = _pickle_dump_impl(module, obj, file, protocol, fix_imports);
397
398exit:
399 return return_value;
400}
401
402PyDoc_STRVAR(_pickle_dumps__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800403"dumps($module, /, obj, protocol=None, *, fix_imports=True)\n"
404"--\n"
405"\n"
Serhiy Storchaka3c1f0f12014-01-27 10:34:22 +0200406"Return the pickled representation of the object as a bytes object.\n"
407"\n"
408"The optional *protocol* argument tells the pickler to use the given\n"
409"protocol; supported protocols are 0, 1, 2, 3 and 4. The default\n"
410"protocol is 3; a backward-incompatible protocol designed for Python 3.\n"
411"\n"
412"Specifying a negative protocol version selects the highest protocol\n"
413"version supported. The higher the protocol used, the more recent the\n"
414"version of Python needed to read the pickle produced.\n"
415"\n"
416"If *fix_imports* is True and *protocol* is less than 3, pickle will\n"
417"try to map the new Python 3 names to the old module names used in\n"
418"Python 2, so that the pickle data stream is readable with Python 2.");
419
420#define _PICKLE_DUMPS_METHODDEF \
421 {"dumps", (PyCFunction)_pickle_dumps, METH_VARARGS|METH_KEYWORDS, _pickle_dumps__doc__},
422
423static PyObject *
424_pickle_dumps_impl(PyModuleDef *module, PyObject *obj, PyObject *protocol, int fix_imports);
425
426static PyObject *
427_pickle_dumps(PyModuleDef *module, PyObject *args, PyObject *kwargs)
428{
429 PyObject *return_value = NULL;
430 static char *_keywords[] = {"obj", "protocol", "fix_imports", NULL};
431 PyObject *obj;
432 PyObject *protocol = NULL;
433 int fix_imports = 1;
434
435 if (!PyArg_ParseTupleAndKeywords(args, kwargs,
436 "O|O$p:dumps", _keywords,
437 &obj, &protocol, &fix_imports))
438 goto exit;
439 return_value = _pickle_dumps_impl(module, obj, protocol, fix_imports);
440
441exit:
442 return return_value;
443}
444
445PyDoc_STRVAR(_pickle_load__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800446"load($module, /, file, *, fix_imports=True, encoding=\'ASCII\',\n"
447" errors=\'strict\')\n"
448"--\n"
449"\n"
Serhiy Storchaka3c1f0f12014-01-27 10:34:22 +0200450"Read and return an object from the pickle data stored in a file.\n"
451"\n"
452"This is equivalent to ``Unpickler(file).load()``, but may be more\n"
453"efficient.\n"
454"\n"
455"The protocol version of the pickle is detected automatically, so no\n"
456"protocol argument is needed. Bytes past the pickled object\'s\n"
457"representation are ignored.\n"
458"\n"
459"The argument *file* must have two methods, a read() method that takes\n"
460"an integer argument, and a readline() method that requires no\n"
461"arguments. Both methods should return bytes. Thus *file* can be a\n"
Martin Panter7462b6492015-11-02 03:37:02 +0000462"binary file object opened for reading, an io.BytesIO object, or any\n"
Serhiy Storchaka3c1f0f12014-01-27 10:34:22 +0200463"other custom object that meets this interface.\n"
464"\n"
465"Optional keyword arguments are *fix_imports*, *encoding* and *errors*,\n"
466"which are used to control compatiblity support for pickle stream\n"
467"generated by Python 2. If *fix_imports* is True, pickle will try to\n"
468"map the old Python 2 names to the new names used in Python 3. The\n"
469"*encoding* and *errors* tell pickle how to decode 8-bit string\n"
470"instances pickled by Python 2; these default to \'ASCII\' and \'strict\',\n"
471"respectively. The *encoding* can be \'bytes\' to read these 8-bit\n"
472"string instances as bytes objects.");
473
474#define _PICKLE_LOAD_METHODDEF \
475 {"load", (PyCFunction)_pickle_load, METH_VARARGS|METH_KEYWORDS, _pickle_load__doc__},
476
477static PyObject *
478_pickle_load_impl(PyModuleDef *module, PyObject *file, int fix_imports, const char *encoding, const char *errors);
479
480static PyObject *
481_pickle_load(PyModuleDef *module, PyObject *args, PyObject *kwargs)
482{
483 PyObject *return_value = NULL;
484 static char *_keywords[] = {"file", "fix_imports", "encoding", "errors", NULL};
485 PyObject *file;
486 int fix_imports = 1;
487 const char *encoding = "ASCII";
488 const char *errors = "strict";
489
490 if (!PyArg_ParseTupleAndKeywords(args, kwargs,
491 "O|$pss:load", _keywords,
492 &file, &fix_imports, &encoding, &errors))
493 goto exit;
494 return_value = _pickle_load_impl(module, file, fix_imports, encoding, errors);
495
496exit:
497 return return_value;
498}
499
500PyDoc_STRVAR(_pickle_loads__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800501"loads($module, /, data, *, fix_imports=True, encoding=\'ASCII\',\n"
502" errors=\'strict\')\n"
503"--\n"
504"\n"
Serhiy Storchaka3c1f0f12014-01-27 10:34:22 +0200505"Read and return an object from the given pickle data.\n"
506"\n"
507"The protocol version of the pickle is detected automatically, so no\n"
508"protocol argument is needed. Bytes past the pickled object\'s\n"
509"representation are ignored.\n"
510"\n"
511"Optional keyword arguments are *fix_imports*, *encoding* and *errors*,\n"
512"which are used to control compatiblity support for pickle stream\n"
513"generated by Python 2. If *fix_imports* is True, pickle will try to\n"
514"map the old Python 2 names to the new names used in Python 3. The\n"
515"*encoding* and *errors* tell pickle how to decode 8-bit string\n"
516"instances pickled by Python 2; these default to \'ASCII\' and \'strict\',\n"
517"respectively. The *encoding* can be \'bytes\' to read these 8-bit\n"
518"string instances as bytes objects.");
519
520#define _PICKLE_LOADS_METHODDEF \
521 {"loads", (PyCFunction)_pickle_loads, METH_VARARGS|METH_KEYWORDS, _pickle_loads__doc__},
522
523static PyObject *
524_pickle_loads_impl(PyModuleDef *module, PyObject *data, int fix_imports, const char *encoding, const char *errors);
525
526static PyObject *
527_pickle_loads(PyModuleDef *module, PyObject *args, PyObject *kwargs)
528{
529 PyObject *return_value = NULL;
530 static char *_keywords[] = {"data", "fix_imports", "encoding", "errors", NULL};
531 PyObject *data;
532 int fix_imports = 1;
533 const char *encoding = "ASCII";
534 const char *errors = "strict";
535
536 if (!PyArg_ParseTupleAndKeywords(args, kwargs,
537 "O|$pss:loads", _keywords,
538 &data, &fix_imports, &encoding, &errors))
539 goto exit;
540 return_value = _pickle_loads_impl(module, data, fix_imports, encoding, errors);
541
542exit:
543 return return_value;
544}
Martin Panter7462b6492015-11-02 03:37:02 +0000545/*[clinic end generated code: output=1ba210152e2261d8 input=a9049054013a1b77]*/