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