blob: e87a22127cfc36acdaa117bece13cb2c803b13f9 [file] [log] [blame]
Serhiy Storchaka1009bf12015-04-03 23:53:51 +03001/*[clinic input]
2preserve
3[clinic start generated code]*/
4
5PyDoc_STRVAR(bytearray_clear__doc__,
6"clear($self, /)\n"
7"--\n"
8"\n"
9"Remove all items from the bytearray.");
10
11#define BYTEARRAY_CLEAR_METHODDEF \
12 {"clear", (PyCFunction)bytearray_clear, METH_NOARGS, bytearray_clear__doc__},
13
14static PyObject *
15bytearray_clear_impl(PyByteArrayObject *self);
16
17static PyObject *
18bytearray_clear(PyByteArrayObject *self, PyObject *Py_UNUSED(ignored))
19{
20 return bytearray_clear_impl(self);
21}
22
23PyDoc_STRVAR(bytearray_copy__doc__,
24"copy($self, /)\n"
25"--\n"
26"\n"
27"Return a copy of B.");
28
29#define BYTEARRAY_COPY_METHODDEF \
30 {"copy", (PyCFunction)bytearray_copy, METH_NOARGS, bytearray_copy__doc__},
31
32static PyObject *
33bytearray_copy_impl(PyByteArrayObject *self);
34
35static PyObject *
36bytearray_copy(PyByteArrayObject *self, PyObject *Py_UNUSED(ignored))
37{
38 return bytearray_copy_impl(self);
39}
40
41PyDoc_STRVAR(bytearray_translate__doc__,
42"translate(table, [deletechars])\n"
43"Return a copy with each character mapped by the given translation table.\n"
44"\n"
45" table\n"
46" Translation table, which must be a bytes object of length 256.\n"
47"\n"
48"All characters occurring in the optional argument deletechars are removed.\n"
49"The remaining characters are mapped through the given translation table.");
50
51#define BYTEARRAY_TRANSLATE_METHODDEF \
52 {"translate", (PyCFunction)bytearray_translate, METH_VARARGS, bytearray_translate__doc__},
53
54static PyObject *
Larry Hastings89964c42015-04-14 18:07:59 -040055bytearray_translate_impl(PyByteArrayObject *self, PyObject *table,
56 int group_right_1, PyObject *deletechars);
Serhiy Storchaka1009bf12015-04-03 23:53:51 +030057
58static PyObject *
59bytearray_translate(PyByteArrayObject *self, PyObject *args)
60{
61 PyObject *return_value = NULL;
62 PyObject *table;
63 int group_right_1 = 0;
64 PyObject *deletechars = NULL;
65
66 switch (PyTuple_GET_SIZE(args)) {
67 case 1:
68 if (!PyArg_ParseTuple(args, "O:translate", &table))
69 goto exit;
70 break;
71 case 2:
72 if (!PyArg_ParseTuple(args, "OO:translate", &table, &deletechars))
73 goto exit;
74 group_right_1 = 1;
75 break;
76 default:
77 PyErr_SetString(PyExc_TypeError, "bytearray.translate requires 1 to 2 arguments");
78 goto exit;
79 }
80 return_value = bytearray_translate_impl(self, table, group_right_1, deletechars);
81
82exit:
83 return return_value;
84}
85
86PyDoc_STRVAR(bytearray_maketrans__doc__,
87"maketrans(frm, to, /)\n"
88"--\n"
89"\n"
90"Return a translation table useable for the bytes or bytearray translate method.\n"
91"\n"
92"The returned table will be one where each byte in frm is mapped to the byte at\n"
93"the same position in to.\n"
94"\n"
95"The bytes objects frm and to must be of the same length.");
96
97#define BYTEARRAY_MAKETRANS_METHODDEF \
98 {"maketrans", (PyCFunction)bytearray_maketrans, METH_VARARGS|METH_STATIC, bytearray_maketrans__doc__},
99
100static PyObject *
101bytearray_maketrans_impl(Py_buffer *frm, Py_buffer *to);
102
103static PyObject *
104bytearray_maketrans(void *null, PyObject *args)
105{
106 PyObject *return_value = NULL;
107 Py_buffer frm = {NULL, NULL};
108 Py_buffer to = {NULL, NULL};
109
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300110 if (!PyArg_ParseTuple(args, "y*y*:maketrans",
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300111 &frm, &to))
112 goto exit;
113 return_value = bytearray_maketrans_impl(&frm, &to);
114
115exit:
116 /* Cleanup for frm */
117 if (frm.obj)
118 PyBuffer_Release(&frm);
119 /* Cleanup for to */
120 if (to.obj)
121 PyBuffer_Release(&to);
122
123 return return_value;
124}
125
126PyDoc_STRVAR(bytearray_replace__doc__,
127"replace($self, old, new, count=-1, /)\n"
128"--\n"
129"\n"
130"Return a copy with all occurrences of substring old replaced by new.\n"
131"\n"
132" count\n"
133" Maximum number of occurrences to replace.\n"
134" -1 (the default value) means replace all occurrences.\n"
135"\n"
136"If the optional argument count is given, only the first count occurrences are\n"
137"replaced.");
138
139#define BYTEARRAY_REPLACE_METHODDEF \
140 {"replace", (PyCFunction)bytearray_replace, METH_VARARGS, bytearray_replace__doc__},
141
142static PyObject *
Larry Hastings89964c42015-04-14 18:07:59 -0400143bytearray_replace_impl(PyByteArrayObject *self, Py_buffer *old,
144 Py_buffer *new, Py_ssize_t count);
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300145
146static PyObject *
147bytearray_replace(PyByteArrayObject *self, PyObject *args)
148{
149 PyObject *return_value = NULL;
150 Py_buffer old = {NULL, NULL};
151 Py_buffer new = {NULL, NULL};
152 Py_ssize_t count = -1;
153
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300154 if (!PyArg_ParseTuple(args, "y*y*|n:replace",
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300155 &old, &new, &count))
156 goto exit;
157 return_value = bytearray_replace_impl(self, &old, &new, count);
158
159exit:
160 /* Cleanup for old */
161 if (old.obj)
162 PyBuffer_Release(&old);
163 /* Cleanup for new */
164 if (new.obj)
165 PyBuffer_Release(&new);
166
167 return return_value;
168}
169
170PyDoc_STRVAR(bytearray_split__doc__,
171"split($self, /, sep=None, maxsplit=-1)\n"
172"--\n"
173"\n"
174"Return a list of the sections in the bytearray, using sep as the delimiter.\n"
175"\n"
176" sep\n"
177" The delimiter according which to split the bytearray.\n"
178" None (the default value) means split on ASCII whitespace characters\n"
179" (space, tab, return, newline, formfeed, vertical tab).\n"
180" maxsplit\n"
181" Maximum number of splits to do.\n"
182" -1 (the default value) means no limit.");
183
184#define BYTEARRAY_SPLIT_METHODDEF \
185 {"split", (PyCFunction)bytearray_split, METH_VARARGS|METH_KEYWORDS, bytearray_split__doc__},
186
187static PyObject *
Larry Hastings89964c42015-04-14 18:07:59 -0400188bytearray_split_impl(PyByteArrayObject *self, PyObject *sep,
189 Py_ssize_t maxsplit);
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300190
191static PyObject *
192bytearray_split(PyByteArrayObject *self, PyObject *args, PyObject *kwargs)
193{
194 PyObject *return_value = NULL;
195 static char *_keywords[] = {"sep", "maxsplit", NULL};
196 PyObject *sep = Py_None;
197 Py_ssize_t maxsplit = -1;
198
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300199 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|On:split", _keywords,
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300200 &sep, &maxsplit))
201 goto exit;
202 return_value = bytearray_split_impl(self, sep, maxsplit);
203
204exit:
205 return return_value;
206}
207
208PyDoc_STRVAR(bytearray_partition__doc__,
209"partition($self, sep, /)\n"
210"--\n"
211"\n"
212"Partition the bytearray into three parts using the given separator.\n"
213"\n"
214"This will search for the separator sep in the bytearray. If the separator is\n"
215"found, returns a 3-tuple containing the part before the separator, the\n"
216"separator itself, and the part after it.\n"
217"\n"
218"If the separator is not found, returns a 3-tuple containing the original\n"
219"bytearray object and two empty bytearray objects.");
220
221#define BYTEARRAY_PARTITION_METHODDEF \
222 {"partition", (PyCFunction)bytearray_partition, METH_O, bytearray_partition__doc__},
223
224PyDoc_STRVAR(bytearray_rpartition__doc__,
225"rpartition($self, sep, /)\n"
226"--\n"
227"\n"
228"Partition the bytes into three parts using the given separator.\n"
229"\n"
230"This will search for the separator sep in the bytearray, starting and the end.\n"
231"If the separator is found, returns a 3-tuple containing the part before the\n"
232"separator, the separator itself, and the part after it.\n"
233"\n"
234"If the separator is not found, returns a 3-tuple containing two empty bytearray\n"
235"objects and the original bytearray object.");
236
237#define BYTEARRAY_RPARTITION_METHODDEF \
238 {"rpartition", (PyCFunction)bytearray_rpartition, METH_O, bytearray_rpartition__doc__},
239
240PyDoc_STRVAR(bytearray_rsplit__doc__,
241"rsplit($self, /, sep=None, maxsplit=-1)\n"
242"--\n"
243"\n"
244"Return a list of the sections in the bytearray, using sep as the delimiter.\n"
245"\n"
246" sep\n"
247" The delimiter according which to split the bytearray.\n"
248" None (the default value) means split on ASCII whitespace characters\n"
249" (space, tab, return, newline, formfeed, vertical tab).\n"
250" maxsplit\n"
251" Maximum number of splits to do.\n"
252" -1 (the default value) means no limit.\n"
253"\n"
254"Splitting is done starting at the end of the bytearray and working to the front.");
255
256#define BYTEARRAY_RSPLIT_METHODDEF \
257 {"rsplit", (PyCFunction)bytearray_rsplit, METH_VARARGS|METH_KEYWORDS, bytearray_rsplit__doc__},
258
259static PyObject *
Larry Hastings89964c42015-04-14 18:07:59 -0400260bytearray_rsplit_impl(PyByteArrayObject *self, PyObject *sep,
261 Py_ssize_t maxsplit);
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300262
263static PyObject *
264bytearray_rsplit(PyByteArrayObject *self, PyObject *args, PyObject *kwargs)
265{
266 PyObject *return_value = NULL;
267 static char *_keywords[] = {"sep", "maxsplit", NULL};
268 PyObject *sep = Py_None;
269 Py_ssize_t maxsplit = -1;
270
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300271 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|On:rsplit", _keywords,
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300272 &sep, &maxsplit))
273 goto exit;
274 return_value = bytearray_rsplit_impl(self, sep, maxsplit);
275
276exit:
277 return return_value;
278}
279
280PyDoc_STRVAR(bytearray_reverse__doc__,
281"reverse($self, /)\n"
282"--\n"
283"\n"
284"Reverse the order of the values in B in place.");
285
286#define BYTEARRAY_REVERSE_METHODDEF \
287 {"reverse", (PyCFunction)bytearray_reverse, METH_NOARGS, bytearray_reverse__doc__},
288
289static PyObject *
290bytearray_reverse_impl(PyByteArrayObject *self);
291
292static PyObject *
293bytearray_reverse(PyByteArrayObject *self, PyObject *Py_UNUSED(ignored))
294{
295 return bytearray_reverse_impl(self);
296}
297
298PyDoc_STRVAR(bytearray_insert__doc__,
299"insert($self, index, item, /)\n"
300"--\n"
301"\n"
302"Insert a single item into the bytearray before the given index.\n"
303"\n"
304" index\n"
305" The index where the value is to be inserted.\n"
306" item\n"
307" The item to be inserted.");
308
309#define BYTEARRAY_INSERT_METHODDEF \
310 {"insert", (PyCFunction)bytearray_insert, METH_VARARGS, bytearray_insert__doc__},
311
312static PyObject *
313bytearray_insert_impl(PyByteArrayObject *self, Py_ssize_t index, int item);
314
315static PyObject *
316bytearray_insert(PyByteArrayObject *self, PyObject *args)
317{
318 PyObject *return_value = NULL;
319 Py_ssize_t index;
320 int item;
321
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300322 if (!PyArg_ParseTuple(args, "nO&:insert",
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300323 &index, _getbytevalue, &item))
324 goto exit;
325 return_value = bytearray_insert_impl(self, index, item);
326
327exit:
328 return return_value;
329}
330
331PyDoc_STRVAR(bytearray_append__doc__,
332"append($self, item, /)\n"
333"--\n"
334"\n"
335"Append a single item to the end of the bytearray.\n"
336"\n"
337" item\n"
338" The item to be appended.");
339
340#define BYTEARRAY_APPEND_METHODDEF \
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300341 {"append", (PyCFunction)bytearray_append, METH_O, bytearray_append__doc__},
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300342
343static PyObject *
344bytearray_append_impl(PyByteArrayObject *self, int item);
345
346static PyObject *
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300347bytearray_append(PyByteArrayObject *self, PyObject *arg)
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300348{
349 PyObject *return_value = NULL;
350 int item;
351
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300352 if (!PyArg_Parse(arg, "O&:append", _getbytevalue, &item))
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300353 goto exit;
354 return_value = bytearray_append_impl(self, item);
355
356exit:
357 return return_value;
358}
359
360PyDoc_STRVAR(bytearray_extend__doc__,
361"extend($self, iterable_of_ints, /)\n"
362"--\n"
363"\n"
364"Append all the items from the iterator or sequence to the end of the bytearray.\n"
365"\n"
366" iterable_of_ints\n"
367" The iterable of items to append.");
368
369#define BYTEARRAY_EXTEND_METHODDEF \
370 {"extend", (PyCFunction)bytearray_extend, METH_O, bytearray_extend__doc__},
371
372PyDoc_STRVAR(bytearray_pop__doc__,
373"pop($self, index=-1, /)\n"
374"--\n"
375"\n"
376"Remove and return a single item from B.\n"
377"\n"
378" index\n"
379" The index from where to remove the item.\n"
380" -1 (the default value) means remove the last item.\n"
381"\n"
382"If no index argument is given, will pop the last item.");
383
384#define BYTEARRAY_POP_METHODDEF \
385 {"pop", (PyCFunction)bytearray_pop, METH_VARARGS, bytearray_pop__doc__},
386
387static PyObject *
388bytearray_pop_impl(PyByteArrayObject *self, Py_ssize_t index);
389
390static PyObject *
391bytearray_pop(PyByteArrayObject *self, PyObject *args)
392{
393 PyObject *return_value = NULL;
394 Py_ssize_t index = -1;
395
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300396 if (!PyArg_ParseTuple(args, "|n:pop",
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300397 &index))
398 goto exit;
399 return_value = bytearray_pop_impl(self, index);
400
401exit:
402 return return_value;
403}
404
405PyDoc_STRVAR(bytearray_remove__doc__,
406"remove($self, value, /)\n"
407"--\n"
408"\n"
409"Remove the first occurrence of a value in the bytearray.\n"
410"\n"
411" value\n"
412" The value to remove.");
413
414#define BYTEARRAY_REMOVE_METHODDEF \
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300415 {"remove", (PyCFunction)bytearray_remove, METH_O, bytearray_remove__doc__},
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300416
417static PyObject *
418bytearray_remove_impl(PyByteArrayObject *self, int value);
419
420static PyObject *
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300421bytearray_remove(PyByteArrayObject *self, PyObject *arg)
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300422{
423 PyObject *return_value = NULL;
424 int value;
425
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300426 if (!PyArg_Parse(arg, "O&:remove", _getbytevalue, &value))
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300427 goto exit;
428 return_value = bytearray_remove_impl(self, value);
429
430exit:
431 return return_value;
432}
433
434PyDoc_STRVAR(bytearray_strip__doc__,
435"strip($self, bytes=None, /)\n"
436"--\n"
437"\n"
438"Strip leading and trailing bytes contained in the argument.\n"
439"\n"
440"If the argument is omitted or None, strip leading and trailing ASCII whitespace.");
441
442#define BYTEARRAY_STRIP_METHODDEF \
443 {"strip", (PyCFunction)bytearray_strip, METH_VARARGS, bytearray_strip__doc__},
444
445static PyObject *
446bytearray_strip_impl(PyByteArrayObject *self, PyObject *bytes);
447
448static PyObject *
449bytearray_strip(PyByteArrayObject *self, PyObject *args)
450{
451 PyObject *return_value = NULL;
452 PyObject *bytes = Py_None;
453
454 if (!PyArg_UnpackTuple(args, "strip",
455 0, 1,
456 &bytes))
457 goto exit;
458 return_value = bytearray_strip_impl(self, bytes);
459
460exit:
461 return return_value;
462}
463
464PyDoc_STRVAR(bytearray_lstrip__doc__,
465"lstrip($self, bytes=None, /)\n"
466"--\n"
467"\n"
468"Strip leading bytes contained in the argument.\n"
469"\n"
470"If the argument is omitted or None, strip leading ASCII whitespace.");
471
472#define BYTEARRAY_LSTRIP_METHODDEF \
473 {"lstrip", (PyCFunction)bytearray_lstrip, METH_VARARGS, bytearray_lstrip__doc__},
474
475static PyObject *
476bytearray_lstrip_impl(PyByteArrayObject *self, PyObject *bytes);
477
478static PyObject *
479bytearray_lstrip(PyByteArrayObject *self, PyObject *args)
480{
481 PyObject *return_value = NULL;
482 PyObject *bytes = Py_None;
483
484 if (!PyArg_UnpackTuple(args, "lstrip",
485 0, 1,
486 &bytes))
487 goto exit;
488 return_value = bytearray_lstrip_impl(self, bytes);
489
490exit:
491 return return_value;
492}
493
494PyDoc_STRVAR(bytearray_rstrip__doc__,
495"rstrip($self, bytes=None, /)\n"
496"--\n"
497"\n"
498"Strip trailing bytes contained in the argument.\n"
499"\n"
500"If the argument is omitted or None, strip trailing ASCII whitespace.");
501
502#define BYTEARRAY_RSTRIP_METHODDEF \
503 {"rstrip", (PyCFunction)bytearray_rstrip, METH_VARARGS, bytearray_rstrip__doc__},
504
505static PyObject *
506bytearray_rstrip_impl(PyByteArrayObject *self, PyObject *bytes);
507
508static PyObject *
509bytearray_rstrip(PyByteArrayObject *self, PyObject *args)
510{
511 PyObject *return_value = NULL;
512 PyObject *bytes = Py_None;
513
514 if (!PyArg_UnpackTuple(args, "rstrip",
515 0, 1,
516 &bytes))
517 goto exit;
518 return_value = bytearray_rstrip_impl(self, bytes);
519
520exit:
521 return return_value;
522}
523
524PyDoc_STRVAR(bytearray_decode__doc__,
525"decode($self, /, encoding=\'utf-8\', errors=\'strict\')\n"
526"--\n"
527"\n"
528"Decode the bytearray using the codec registered for encoding.\n"
529"\n"
530" encoding\n"
531" The encoding with which to decode the bytearray.\n"
532" errors\n"
533" The error handling scheme to use for the handling of decoding errors.\n"
534" The default is \'strict\' meaning that decoding errors raise a\n"
535" UnicodeDecodeError. Other possible values are \'ignore\' and \'replace\'\n"
536" as well as any other name registered with codecs.register_error that\n"
537" can handle UnicodeDecodeErrors.");
538
539#define BYTEARRAY_DECODE_METHODDEF \
540 {"decode", (PyCFunction)bytearray_decode, METH_VARARGS|METH_KEYWORDS, bytearray_decode__doc__},
541
542static PyObject *
Larry Hastings89964c42015-04-14 18:07:59 -0400543bytearray_decode_impl(PyByteArrayObject *self, const char *encoding,
544 const char *errors);
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300545
546static PyObject *
547bytearray_decode(PyByteArrayObject *self, PyObject *args, PyObject *kwargs)
548{
549 PyObject *return_value = NULL;
550 static char *_keywords[] = {"encoding", "errors", NULL};
551 const char *encoding = NULL;
552 const char *errors = NULL;
553
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300554 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ss:decode", _keywords,
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300555 &encoding, &errors))
556 goto exit;
557 return_value = bytearray_decode_impl(self, encoding, errors);
558
559exit:
560 return return_value;
561}
562
563PyDoc_STRVAR(bytearray_join__doc__,
564"join($self, iterable_of_bytes, /)\n"
565"--\n"
566"\n"
567"Concatenate any number of bytes/bytearray objects.\n"
568"\n"
569"The bytearray whose method is called is inserted in between each pair.\n"
570"\n"
571"The result is returned as a new bytearray object.");
572
573#define BYTEARRAY_JOIN_METHODDEF \
574 {"join", (PyCFunction)bytearray_join, METH_O, bytearray_join__doc__},
575
576PyDoc_STRVAR(bytearray_splitlines__doc__,
577"splitlines($self, /, keepends=False)\n"
578"--\n"
579"\n"
580"Return a list of the lines in the bytearray, breaking at line boundaries.\n"
581"\n"
582"Line breaks are not included in the resulting list unless keepends is given and\n"
583"true.");
584
585#define BYTEARRAY_SPLITLINES_METHODDEF \
586 {"splitlines", (PyCFunction)bytearray_splitlines, METH_VARARGS|METH_KEYWORDS, bytearray_splitlines__doc__},
587
588static PyObject *
589bytearray_splitlines_impl(PyByteArrayObject *self, int keepends);
590
591static PyObject *
592bytearray_splitlines(PyByteArrayObject *self, PyObject *args, PyObject *kwargs)
593{
594 PyObject *return_value = NULL;
595 static char *_keywords[] = {"keepends", NULL};
596 int keepends = 0;
597
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300598 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i:splitlines", _keywords,
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300599 &keepends))
600 goto exit;
601 return_value = bytearray_splitlines_impl(self, keepends);
602
603exit:
604 return return_value;
605}
606
607PyDoc_STRVAR(bytearray_fromhex__doc__,
608"fromhex($type, string, /)\n"
609"--\n"
610"\n"
611"Create a bytearray object from a string of hexadecimal numbers.\n"
612"\n"
613"Spaces between two numbers are accepted.\n"
614"Example: bytearray.fromhex(\'B9 01EF\') -> bytearray(b\'\\\\xb9\\\\x01\\\\xef\')");
615
616#define BYTEARRAY_FROMHEX_METHODDEF \
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300617 {"fromhex", (PyCFunction)bytearray_fromhex, METH_O|METH_CLASS, bytearray_fromhex__doc__},
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300618
619static PyObject *
620bytearray_fromhex_impl(PyObject*cls, PyObject *string);
621
622static PyObject *
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300623bytearray_fromhex(PyTypeObject *cls, PyObject *arg)
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300624{
625 PyObject *return_value = NULL;
626 PyObject *string;
627
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300628 if (!PyArg_Parse(arg, "U:fromhex", &string))
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300629 goto exit;
630 return_value = bytearray_fromhex_impl((PyObject*)cls, string);
631
632exit:
633 return return_value;
634}
635
636PyDoc_STRVAR(bytearray_reduce__doc__,
637"__reduce__($self, /)\n"
638"--\n"
639"\n"
640"Return state information for pickling.");
641
642#define BYTEARRAY_REDUCE_METHODDEF \
643 {"__reduce__", (PyCFunction)bytearray_reduce, METH_NOARGS, bytearray_reduce__doc__},
644
645static PyObject *
646bytearray_reduce_impl(PyByteArrayObject *self);
647
648static PyObject *
649bytearray_reduce(PyByteArrayObject *self, PyObject *Py_UNUSED(ignored))
650{
651 return bytearray_reduce_impl(self);
652}
653
654PyDoc_STRVAR(bytearray_reduce_ex__doc__,
655"__reduce_ex__($self, proto=0, /)\n"
656"--\n"
657"\n"
658"Return state information for pickling.");
659
660#define BYTEARRAY_REDUCE_EX_METHODDEF \
661 {"__reduce_ex__", (PyCFunction)bytearray_reduce_ex, METH_VARARGS, bytearray_reduce_ex__doc__},
662
663static PyObject *
664bytearray_reduce_ex_impl(PyByteArrayObject *self, int proto);
665
666static PyObject *
667bytearray_reduce_ex(PyByteArrayObject *self, PyObject *args)
668{
669 PyObject *return_value = NULL;
670 int proto = 0;
671
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300672 if (!PyArg_ParseTuple(args, "|i:__reduce_ex__",
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300673 &proto))
674 goto exit;
675 return_value = bytearray_reduce_ex_impl(self, proto);
676
677exit:
678 return return_value;
679}
680
681PyDoc_STRVAR(bytearray_sizeof__doc__,
682"__sizeof__($self, /)\n"
683"--\n"
684"\n"
685"Returns the size of the bytearray object in memory, in bytes.");
686
687#define BYTEARRAY_SIZEOF_METHODDEF \
688 {"__sizeof__", (PyCFunction)bytearray_sizeof, METH_NOARGS, bytearray_sizeof__doc__},
689
690static PyObject *
691bytearray_sizeof_impl(PyByteArrayObject *self);
692
693static PyObject *
694bytearray_sizeof(PyByteArrayObject *self, PyObject *Py_UNUSED(ignored))
695{
696 return bytearray_sizeof_impl(self);
697}
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300698/*[clinic end generated code: output=966c15ff22c5e243 input=a9049054013a1b77]*/