1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
|
/*[clinic input]
preserve
[clinic start generated code]*/
PyDoc_STRVAR(bytes_split__doc__,
"split($self, /, sep=None, maxsplit=-1)\n"
"--\n"
"\n"
"Return a list of the sections in the bytes, using sep as the delimiter.\n"
"\n"
" sep\n"
" The delimiter according which to split the bytes.\n"
" None (the default value) means split on ASCII whitespace characters\n"
" (space, tab, return, newline, formfeed, vertical tab).\n"
" maxsplit\n"
" Maximum number of splits to do.\n"
" -1 (the default value) means no limit.");
#define BYTES_SPLIT_METHODDEF \
{"split", (PyCFunction)bytes_split, METH_VARARGS|METH_KEYWORDS, bytes_split__doc__},
static PyObject *
bytes_split_impl(PyBytesObject *self, PyObject *sep, Py_ssize_t maxsplit);
static PyObject *
bytes_split(PyBytesObject *self, PyObject *args, PyObject *kwargs)
{
PyObject *return_value = NULL;
static char *_keywords[] = {"sep", "maxsplit", NULL};
PyObject *sep = Py_None;
Py_ssize_t maxsplit = -1;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|On:split", _keywords,
&sep, &maxsplit))
goto exit;
return_value = bytes_split_impl(self, sep, maxsplit);
exit:
return return_value;
}
PyDoc_STRVAR(bytes_partition__doc__,
"partition($self, sep, /)\n"
"--\n"
"\n"
"Partition the bytes into three parts using the given separator.\n"
"\n"
"This will search for the separator sep in the bytes. If the separator is found,\n"
"returns a 3-tuple containing the part before the separator, the separator\n"
"itself, and the part after it.\n"
"\n"
"If the separator is not found, returns a 3-tuple containing the original bytes\n"
"object and two empty bytes objects.");
#define BYTES_PARTITION_METHODDEF \
{"partition", (PyCFunction)bytes_partition, METH_O, bytes_partition__doc__},
static PyObject *
bytes_partition_impl(PyBytesObject *self, Py_buffer *sep);
static PyObject *
bytes_partition(PyBytesObject *self, PyObject *arg)
{
PyObject *return_value = NULL;
Py_buffer sep = {NULL, NULL};
if (!PyArg_Parse(arg, "y*:partition", &sep))
goto exit;
return_value = bytes_partition_impl(self, &sep);
exit:
/* Cleanup for sep */
if (sep.obj)
PyBuffer_Release(&sep);
return return_value;
}
PyDoc_STRVAR(bytes_rpartition__doc__,
"rpartition($self, sep, /)\n"
"--\n"
"\n"
"Partition the bytes into three parts using the given separator.\n"
"\n"
"This will search for the separator sep in the bytes, starting and the end. If\n"
"the separator is found, returns a 3-tuple containing the part before the\n"
"separator, the separator itself, and the part after it.\n"
"\n"
"If the separator is not found, returns a 3-tuple containing two empty bytes\n"
"objects and the original bytes object.");
#define BYTES_RPARTITION_METHODDEF \
{"rpartition", (PyCFunction)bytes_rpartition, METH_O, bytes_rpartition__doc__},
static PyObject *
bytes_rpartition_impl(PyBytesObject *self, Py_buffer *sep);
static PyObject *
bytes_rpartition(PyBytesObject *self, PyObject *arg)
{
PyObject *return_value = NULL;
Py_buffer sep = {NULL, NULL};
if (!PyArg_Parse(arg, "y*:rpartition", &sep))
goto exit;
return_value = bytes_rpartition_impl(self, &sep);
exit:
/* Cleanup for sep */
if (sep.obj)
PyBuffer_Release(&sep);
return return_value;
}
PyDoc_STRVAR(bytes_rsplit__doc__,
"rsplit($self, /, sep=None, maxsplit=-1)\n"
"--\n"
"\n"
"Return a list of the sections in the bytes, using sep as the delimiter.\n"
"\n"
" sep\n"
" The delimiter according which to split the bytes.\n"
" None (the default value) means split on ASCII whitespace characters\n"
" (space, tab, return, newline, formfeed, vertical tab).\n"
" maxsplit\n"
" Maximum number of splits to do.\n"
" -1 (the default value) means no limit.\n"
"\n"
"Splitting is done starting at the end of the bytes and working to the front.");
#define BYTES_RSPLIT_METHODDEF \
{"rsplit", (PyCFunction)bytes_rsplit, METH_VARARGS|METH_KEYWORDS, bytes_rsplit__doc__},
static PyObject *
bytes_rsplit_impl(PyBytesObject *self, PyObject *sep, Py_ssize_t maxsplit);
static PyObject *
bytes_rsplit(PyBytesObject *self, PyObject *args, PyObject *kwargs)
{
PyObject *return_value = NULL;
static char *_keywords[] = {"sep", "maxsplit", NULL};
PyObject *sep = Py_None;
Py_ssize_t maxsplit = -1;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|On:rsplit", _keywords,
&sep, &maxsplit))
goto exit;
return_value = bytes_rsplit_impl(self, sep, maxsplit);
exit:
return return_value;
}
PyDoc_STRVAR(bytes_join__doc__,
"join($self, iterable_of_bytes, /)\n"
"--\n"
"\n"
"Concatenate any number of bytes objects.\n"
"\n"
"The bytes whose method is called is inserted in between each pair.\n"
"\n"
"The result is returned as a new bytes object.\n"
"\n"
"Example: b\'.\'.join([b\'ab\', b\'pq\', b\'rs\']) -> b\'ab.pq.rs\'.");
#define BYTES_JOIN_METHODDEF \
{"join", (PyCFunction)bytes_join, METH_O, bytes_join__doc__},
PyDoc_STRVAR(bytes_strip__doc__,
"strip($self, bytes=None, /)\n"
"--\n"
"\n"
"Strip leading and trailing bytes contained in the argument.\n"
"\n"
"If the argument is omitted or None, strip leading and trailing ASCII whitespace.");
#define BYTES_STRIP_METHODDEF \
{"strip", (PyCFunction)bytes_strip, METH_VARARGS, bytes_strip__doc__},
static PyObject *
bytes_strip_impl(PyBytesObject *self, PyObject *bytes);
static PyObject *
bytes_strip(PyBytesObject *self, PyObject *args)
{
PyObject *return_value = NULL;
PyObject *bytes = Py_None;
if (!PyArg_UnpackTuple(args, "strip",
0, 1,
&bytes))
goto exit;
return_value = bytes_strip_impl(self, bytes);
exit:
return return_value;
}
PyDoc_STRVAR(bytes_lstrip__doc__,
"lstrip($self, bytes=None, /)\n"
"--\n"
"\n"
"Strip leading bytes contained in the argument.\n"
"\n"
"If the argument is omitted or None, strip leading ASCII whitespace.");
#define BYTES_LSTRIP_METHODDEF \
{"lstrip", (PyCFunction)bytes_lstrip, METH_VARARGS, bytes_lstrip__doc__},
static PyObject *
bytes_lstrip_impl(PyBytesObject *self, PyObject *bytes);
static PyObject *
bytes_lstrip(PyBytesObject *self, PyObject *args)
{
PyObject *return_value = NULL;
PyObject *bytes = Py_None;
if (!PyArg_UnpackTuple(args, "lstrip",
0, 1,
&bytes))
goto exit;
return_value = bytes_lstrip_impl(self, bytes);
exit:
return return_value;
}
PyDoc_STRVAR(bytes_rstrip__doc__,
"rstrip($self, bytes=None, /)\n"
"--\n"
"\n"
"Strip trailing bytes contained in the argument.\n"
"\n"
"If the argument is omitted or None, strip trailing ASCII whitespace.");
#define BYTES_RSTRIP_METHODDEF \
{"rstrip", (PyCFunction)bytes_rstrip, METH_VARARGS, bytes_rstrip__doc__},
static PyObject *
bytes_rstrip_impl(PyBytesObject *self, PyObject *bytes);
static PyObject *
bytes_rstrip(PyBytesObject *self, PyObject *args)
{
PyObject *return_value = NULL;
PyObject *bytes = Py_None;
if (!PyArg_UnpackTuple(args, "rstrip",
0, 1,
&bytes))
goto exit;
return_value = bytes_rstrip_impl(self, bytes);
exit:
return return_value;
}
PyDoc_STRVAR(bytes_translate__doc__,
"translate(table, [deletechars])\n"
"Return a copy with each character mapped by the given translation table.\n"
"\n"
" table\n"
" Translation table, which must be a bytes object of length 256.\n"
"\n"
"All characters occurring in the optional argument deletechars are removed.\n"
"The remaining characters are mapped through the given translation table.");
#define BYTES_TRANSLATE_METHODDEF \
{"translate", (PyCFunction)bytes_translate, METH_VARARGS, bytes_translate__doc__},
static PyObject *
bytes_translate_impl(PyBytesObject *self, PyObject *table, int group_right_1,
PyObject *deletechars);
static PyObject *
bytes_translate(PyBytesObject *self, PyObject *args)
{
PyObject *return_value = NULL;
PyObject *table;
int group_right_1 = 0;
PyObject *deletechars = NULL;
switch (PyTuple_GET_SIZE(args)) {
case 1:
if (!PyArg_ParseTuple(args, "O:translate", &table))
goto exit;
break;
case 2:
if (!PyArg_ParseTuple(args, "OO:translate", &table, &deletechars))
goto exit;
group_right_1 = 1;
break;
default:
PyErr_SetString(PyExc_TypeError, "bytes.translate requires 1 to 2 arguments");
goto exit;
}
return_value = bytes_translate_impl(self, table, group_right_1, deletechars);
exit:
return return_value;
}
PyDoc_STRVAR(bytes_maketrans__doc__,
"maketrans(frm, to, /)\n"
"--\n"
"\n"
"Return a translation table useable for the bytes or bytearray translate method.\n"
"\n"
"The returned table will be one where each byte in frm is mapped to the byte at\n"
"the same position in to.\n"
"\n"
"The bytes objects frm and to must be of the same length.");
#define BYTES_MAKETRANS_METHODDEF \
{"maketrans", (PyCFunction)bytes_maketrans, METH_VARARGS|METH_STATIC, bytes_maketrans__doc__},
static PyObject *
bytes_maketrans_impl(Py_buffer *frm, Py_buffer *to);
static PyObject *
bytes_maketrans(void *null, PyObject *args)
{
PyObject *return_value = NULL;
Py_buffer frm = {NULL, NULL};
Py_buffer to = {NULL, NULL};
if (!PyArg_ParseTuple(args, "y*y*:maketrans",
&frm, &to))
goto exit;
return_value = bytes_maketrans_impl(&frm, &to);
exit:
/* Cleanup for frm */
if (frm.obj)
PyBuffer_Release(&frm);
/* Cleanup for to */
if (to.obj)
PyBuffer_Release(&to);
return return_value;
}
PyDoc_STRVAR(bytes_replace__doc__,
"replace($self, old, new, count=-1, /)\n"
"--\n"
"\n"
"Return a copy with all occurrences of substring old replaced by new.\n"
"\n"
" count\n"
" Maximum number of occurrences to replace.\n"
" -1 (the default value) means replace all occurrences.\n"
"\n"
"If the optional argument count is given, only the first count occurrences are\n"
"replaced.");
#define BYTES_REPLACE_METHODDEF \
{"replace", (PyCFunction)bytes_replace, METH_VARARGS, bytes_replace__doc__},
static PyObject *
bytes_replace_impl(PyBytesObject *self, Py_buffer *old, Py_buffer *new,
Py_ssize_t count);
static PyObject *
bytes_replace(PyBytesObject *self, PyObject *args)
{
PyObject *return_value = NULL;
Py_buffer old = {NULL, NULL};
Py_buffer new = {NULL, NULL};
Py_ssize_t count = -1;
if (!PyArg_ParseTuple(args, "y*y*|n:replace",
&old, &new, &count))
goto exit;
return_value = bytes_replace_impl(self, &old, &new, count);
exit:
/* Cleanup for old */
if (old.obj)
PyBuffer_Release(&old);
/* Cleanup for new */
if (new.obj)
PyBuffer_Release(&new);
return return_value;
}
PyDoc_STRVAR(bytes_decode__doc__,
"decode($self, /, encoding=\'utf-8\', errors=\'strict\')\n"
"--\n"
"\n"
"Decode the bytes using the codec registered for encoding.\n"
"\n"
" encoding\n"
" The encoding with which to decode the bytes.\n"
" errors\n"
" The error handling scheme to use for the handling of decoding errors.\n"
" The default is \'strict\' meaning that decoding errors raise a\n"
" UnicodeDecodeError. Other possible values are \'ignore\' and \'replace\'\n"
" as well as any other name registered with codecs.register_error that\n"
" can handle UnicodeDecodeErrors.");
#define BYTES_DECODE_METHODDEF \
{"decode", (PyCFunction)bytes_decode, METH_VARARGS|METH_KEYWORDS, bytes_decode__doc__},
static PyObject *
bytes_decode_impl(PyBytesObject *self, const char *encoding,
const char *errors);
static PyObject *
bytes_decode(PyBytesObject *self, PyObject *args, PyObject *kwargs)
{
PyObject *return_value = NULL;
static char *_keywords[] = {"encoding", "errors", NULL};
const char *encoding = NULL;
const char *errors = NULL;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ss:decode", _keywords,
&encoding, &errors))
goto exit;
return_value = bytes_decode_impl(self, encoding, errors);
exit:
return return_value;
}
PyDoc_STRVAR(bytes_splitlines__doc__,
"splitlines($self, /, keepends=False)\n"
"--\n"
"\n"
"Return a list of the lines in the bytes, breaking at line boundaries.\n"
"\n"
"Line breaks are not included in the resulting list unless keepends is given and\n"
"true.");
#define BYTES_SPLITLINES_METHODDEF \
{"splitlines", (PyCFunction)bytes_splitlines, METH_VARARGS|METH_KEYWORDS, bytes_splitlines__doc__},
static PyObject *
bytes_splitlines_impl(PyBytesObject *self, int keepends);
static PyObject *
bytes_splitlines(PyBytesObject *self, PyObject *args, PyObject *kwargs)
{
PyObject *return_value = NULL;
static char *_keywords[] = {"keepends", NULL};
int keepends = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i:splitlines", _keywords,
&keepends))
goto exit;
return_value = bytes_splitlines_impl(self, keepends);
exit:
return return_value;
}
PyDoc_STRVAR(bytes_fromhex__doc__,
"fromhex($type, string, /)\n"
"--\n"
"\n"
"Create a bytes object from a string of hexadecimal numbers.\n"
"\n"
"Spaces between two numbers are accepted.\n"
"Example: bytes.fromhex(\'B9 01EF\') -> b\'\\\\xb9\\\\x01\\\\xef\'.");
#define BYTES_FROMHEX_METHODDEF \
{"fromhex", (PyCFunction)bytes_fromhex, METH_O|METH_CLASS, bytes_fromhex__doc__},
static PyObject *
bytes_fromhex_impl(PyTypeObject *type, PyObject *string);
static PyObject *
bytes_fromhex(PyTypeObject *type, PyObject *arg)
{
PyObject *return_value = NULL;
PyObject *string;
if (!PyArg_Parse(arg, "U:fromhex", &string))
goto exit;
return_value = bytes_fromhex_impl(type, string);
exit:
return return_value;
}
/*[clinic end generated code: output=d0e9f5a1c0682910 input=a9049054013a1b77]*/
|