#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
# include "pycore_gc.h"
# include "pycore_runtime.h"
#endif
#include "pycore_abstract.h"
#include "pycore_modsupport.h"
static int
bytearray___init___impl(PyByteArrayObject *self, PyObject *arg,
const char *encoding, const char *errors);
static int
bytearray___init__(PyObject *self, PyObject *args, PyObject *kwargs)
{ … }
PyDoc_STRVAR(bytearray_find__doc__,
"find($self, sub[, start[, end]], /)\n"
"--\n"
"\n"
"Return the lowest index in B where subsection \'sub\' is found, such that \'sub\' is contained within B[start:end].\n"
"\n"
" start\n"
" Optional start position. Default: start of the bytes.\n"
" end\n"
" Optional stop position. Default: end of the bytes.\n"
"\n"
"Return -1 on failure.");
#define BYTEARRAY_FIND_METHODDEF …
static PyObject *
bytearray_find_impl(PyByteArrayObject *self, PyObject *sub, Py_ssize_t start,
Py_ssize_t end);
static PyObject *
bytearray_find(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t nargs)
{ … }
PyDoc_STRVAR(bytearray_count__doc__,
"count($self, sub[, start[, end]], /)\n"
"--\n"
"\n"
"Return the number of non-overlapping occurrences of subsection \'sub\' in bytes B[start:end].\n"
"\n"
" start\n"
" Optional start position. Default: start of the bytes.\n"
" end\n"
" Optional stop position. Default: end of the bytes.");
#define BYTEARRAY_COUNT_METHODDEF …
static PyObject *
bytearray_count_impl(PyByteArrayObject *self, PyObject *sub,
Py_ssize_t start, Py_ssize_t end);
static PyObject *
bytearray_count(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t nargs)
{ … }
PyDoc_STRVAR(bytearray_clear__doc__,
"clear($self, /)\n"
"--\n"
"\n"
"Remove all items from the bytearray.");
#define BYTEARRAY_CLEAR_METHODDEF …
static PyObject *
bytearray_clear_impl(PyByteArrayObject *self);
static PyObject *
bytearray_clear(PyByteArrayObject *self, PyObject *Py_UNUSED(ignored))
{ … }
PyDoc_STRVAR(bytearray_copy__doc__,
"copy($self, /)\n"
"--\n"
"\n"
"Return a copy of B.");
#define BYTEARRAY_COPY_METHODDEF …
static PyObject *
bytearray_copy_impl(PyByteArrayObject *self);
static PyObject *
bytearray_copy(PyByteArrayObject *self, PyObject *Py_UNUSED(ignored))
{ … }
PyDoc_STRVAR(bytearray_index__doc__,
"index($self, sub[, start[, end]], /)\n"
"--\n"
"\n"
"Return the lowest index in B where subsection \'sub\' is found, such that \'sub\' is contained within B[start:end].\n"
"\n"
" start\n"
" Optional start position. Default: start of the bytes.\n"
" end\n"
" Optional stop position. Default: end of the bytes.\n"
"\n"
"Raise ValueError if the subsection is not found.");
#define BYTEARRAY_INDEX_METHODDEF …
static PyObject *
bytearray_index_impl(PyByteArrayObject *self, PyObject *sub,
Py_ssize_t start, Py_ssize_t end);
static PyObject *
bytearray_index(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t nargs)
{ … }
PyDoc_STRVAR(bytearray_rfind__doc__,
"rfind($self, sub[, start[, end]], /)\n"
"--\n"
"\n"
"Return the highest index in B where subsection \'sub\' is found, such that \'sub\' is contained within B[start:end].\n"
"\n"
" start\n"
" Optional start position. Default: start of the bytes.\n"
" end\n"
" Optional stop position. Default: end of the bytes.\n"
"\n"
"Return -1 on failure.");
#define BYTEARRAY_RFIND_METHODDEF …
static PyObject *
bytearray_rfind_impl(PyByteArrayObject *self, PyObject *sub,
Py_ssize_t start, Py_ssize_t end);
static PyObject *
bytearray_rfind(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t nargs)
{ … }
PyDoc_STRVAR(bytearray_rindex__doc__,
"rindex($self, sub[, start[, end]], /)\n"
"--\n"
"\n"
"Return the highest index in B where subsection \'sub\' is found, such that \'sub\' is contained within B[start:end].\n"
"\n"
" start\n"
" Optional start position. Default: start of the bytes.\n"
" end\n"
" Optional stop position. Default: end of the bytes.\n"
"\n"
"Raise ValueError if the subsection is not found.");
#define BYTEARRAY_RINDEX_METHODDEF …
static PyObject *
bytearray_rindex_impl(PyByteArrayObject *self, PyObject *sub,
Py_ssize_t start, Py_ssize_t end);
static PyObject *
bytearray_rindex(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t nargs)
{ … }
PyDoc_STRVAR(bytearray_startswith__doc__,
"startswith($self, prefix[, start[, end]], /)\n"
"--\n"
"\n"
"Return True if the bytearray starts with the specified prefix, False otherwise.\n"
"\n"
" prefix\n"
" A bytes or a tuple of bytes to try.\n"
" start\n"
" Optional start position. Default: start of the bytearray.\n"
" end\n"
" Optional stop position. Default: end of the bytearray.");
#define BYTEARRAY_STARTSWITH_METHODDEF …
static PyObject *
bytearray_startswith_impl(PyByteArrayObject *self, PyObject *subobj,
Py_ssize_t start, Py_ssize_t end);
static PyObject *
bytearray_startswith(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t nargs)
{ … }
PyDoc_STRVAR(bytearray_endswith__doc__,
"endswith($self, suffix[, start[, end]], /)\n"
"--\n"
"\n"
"Return True if the bytearray ends with the specified suffix, False otherwise.\n"
"\n"
" suffix\n"
" A bytes or a tuple of bytes to try.\n"
" start\n"
" Optional start position. Default: start of the bytearray.\n"
" end\n"
" Optional stop position. Default: end of the bytearray.");
#define BYTEARRAY_ENDSWITH_METHODDEF …
static PyObject *
bytearray_endswith_impl(PyByteArrayObject *self, PyObject *subobj,
Py_ssize_t start, Py_ssize_t end);
static PyObject *
bytearray_endswith(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t nargs)
{ … }
PyDoc_STRVAR(bytearray_removeprefix__doc__,
"removeprefix($self, prefix, /)\n"
"--\n"
"\n"
"Return a bytearray with the given prefix string removed if present.\n"
"\n"
"If the bytearray starts with the prefix string, return\n"
"bytearray[len(prefix):]. Otherwise, return a copy of the original\n"
"bytearray.");
#define BYTEARRAY_REMOVEPREFIX_METHODDEF …
static PyObject *
bytearray_removeprefix_impl(PyByteArrayObject *self, Py_buffer *prefix);
static PyObject *
bytearray_removeprefix(PyByteArrayObject *self, PyObject *arg)
{ … }
PyDoc_STRVAR(bytearray_removesuffix__doc__,
"removesuffix($self, suffix, /)\n"
"--\n"
"\n"
"Return a bytearray with the given suffix string removed if present.\n"
"\n"
"If the bytearray ends with the suffix string and that suffix is not\n"
"empty, return bytearray[:-len(suffix)]. Otherwise, return a copy of\n"
"the original bytearray.");
#define BYTEARRAY_REMOVESUFFIX_METHODDEF …
static PyObject *
bytearray_removesuffix_impl(PyByteArrayObject *self, Py_buffer *suffix);
static PyObject *
bytearray_removesuffix(PyByteArrayObject *self, PyObject *arg)
{ … }
PyDoc_STRVAR(bytearray_translate__doc__,
"translate($self, table, /, delete=b\'\')\n"
"--\n"
"\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 delete are removed.\n"
"The remaining characters are mapped through the given translation table.");
#define BYTEARRAY_TRANSLATE_METHODDEF …
static PyObject *
bytearray_translate_impl(PyByteArrayObject *self, PyObject *table,
PyObject *deletechars);
static PyObject *
bytearray_translate(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{ … }
PyDoc_STRVAR(bytearray_maketrans__doc__,
"maketrans(frm, to, /)\n"
"--\n"
"\n"
"Return a translation table usable 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 BYTEARRAY_MAKETRANS_METHODDEF …
static PyObject *
bytearray_maketrans_impl(Py_buffer *frm, Py_buffer *to);
static PyObject *
bytearray_maketrans(void *null, PyObject *const *args, Py_ssize_t nargs)
{ … }
PyDoc_STRVAR(bytearray_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 BYTEARRAY_REPLACE_METHODDEF …
static PyObject *
bytearray_replace_impl(PyByteArrayObject *self, Py_buffer *old,
Py_buffer *new, Py_ssize_t count);
static PyObject *
bytearray_replace(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t nargs)
{ … }
PyDoc_STRVAR(bytearray_split__doc__,
"split($self, /, sep=None, maxsplit=-1)\n"
"--\n"
"\n"
"Return a list of the sections in the bytearray, using sep as the delimiter.\n"
"\n"
" sep\n"
" The delimiter according which to split the bytearray.\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 BYTEARRAY_SPLIT_METHODDEF …
static PyObject *
bytearray_split_impl(PyByteArrayObject *self, PyObject *sep,
Py_ssize_t maxsplit);
static PyObject *
bytearray_split(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{ … }
PyDoc_STRVAR(bytearray_partition__doc__,
"partition($self, sep, /)\n"
"--\n"
"\n"
"Partition the bytearray into three parts using the given separator.\n"
"\n"
"This will search for the separator sep in the bytearray. If the separator is\n"
"found, returns a 3-tuple containing the part before the separator, the\n"
"separator itself, and the part after it as new bytearray objects.\n"
"\n"
"If the separator is not found, returns a 3-tuple containing the copy of the\n"
"original bytearray object and two empty bytearray objects.");
#define BYTEARRAY_PARTITION_METHODDEF …
PyDoc_STRVAR(bytearray_rpartition__doc__,
"rpartition($self, sep, /)\n"
"--\n"
"\n"
"Partition the bytearray into three parts using the given separator.\n"
"\n"
"This will search for the separator sep in the bytearray, starting at the end.\n"
"If the separator is found, returns a 3-tuple containing the part before the\n"
"separator, the separator itself, and the part after it as new bytearray\n"
"objects.\n"
"\n"
"If the separator is not found, returns a 3-tuple containing two empty bytearray\n"
"objects and the copy of the original bytearray object.");
#define BYTEARRAY_RPARTITION_METHODDEF …
PyDoc_STRVAR(bytearray_rsplit__doc__,
"rsplit($self, /, sep=None, maxsplit=-1)\n"
"--\n"
"\n"
"Return a list of the sections in the bytearray, using sep as the delimiter.\n"
"\n"
" sep\n"
" The delimiter according which to split the bytearray.\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 bytearray and working to the front.");
#define BYTEARRAY_RSPLIT_METHODDEF …
static PyObject *
bytearray_rsplit_impl(PyByteArrayObject *self, PyObject *sep,
Py_ssize_t maxsplit);
static PyObject *
bytearray_rsplit(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{ … }
PyDoc_STRVAR(bytearray_reverse__doc__,
"reverse($self, /)\n"
"--\n"
"\n"
"Reverse the order of the values in B in place.");
#define BYTEARRAY_REVERSE_METHODDEF …
static PyObject *
bytearray_reverse_impl(PyByteArrayObject *self);
static PyObject *
bytearray_reverse(PyByteArrayObject *self, PyObject *Py_UNUSED(ignored))
{ … }
PyDoc_STRVAR(bytearray_insert__doc__,
"insert($self, index, item, /)\n"
"--\n"
"\n"
"Insert a single item into the bytearray before the given index.\n"
"\n"
" index\n"
" The index where the value is to be inserted.\n"
" item\n"
" The item to be inserted.");
#define BYTEARRAY_INSERT_METHODDEF …
static PyObject *
bytearray_insert_impl(PyByteArrayObject *self, Py_ssize_t index, int item);
static PyObject *
bytearray_insert(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t nargs)
{ … }
PyDoc_STRVAR(bytearray_append__doc__,
"append($self, item, /)\n"
"--\n"
"\n"
"Append a single item to the end of the bytearray.\n"
"\n"
" item\n"
" The item to be appended.");
#define BYTEARRAY_APPEND_METHODDEF …
static PyObject *
bytearray_append_impl(PyByteArrayObject *self, int item);
static PyObject *
bytearray_append(PyByteArrayObject *self, PyObject *arg)
{ … }
PyDoc_STRVAR(bytearray_extend__doc__,
"extend($self, iterable_of_ints, /)\n"
"--\n"
"\n"
"Append all the items from the iterator or sequence to the end of the bytearray.\n"
"\n"
" iterable_of_ints\n"
" The iterable of items to append.");
#define BYTEARRAY_EXTEND_METHODDEF …
PyDoc_STRVAR(bytearray_pop__doc__,
"pop($self, index=-1, /)\n"
"--\n"
"\n"
"Remove and return a single item from B.\n"
"\n"
" index\n"
" The index from where to remove the item.\n"
" -1 (the default value) means remove the last item.\n"
"\n"
"If no index argument is given, will pop the last item.");
#define BYTEARRAY_POP_METHODDEF …
static PyObject *
bytearray_pop_impl(PyByteArrayObject *self, Py_ssize_t index);
static PyObject *
bytearray_pop(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t nargs)
{ … }
PyDoc_STRVAR(bytearray_remove__doc__,
"remove($self, value, /)\n"
"--\n"
"\n"
"Remove the first occurrence of a value in the bytearray.\n"
"\n"
" value\n"
" The value to remove.");
#define BYTEARRAY_REMOVE_METHODDEF …
static PyObject *
bytearray_remove_impl(PyByteArrayObject *self, int value);
static PyObject *
bytearray_remove(PyByteArrayObject *self, PyObject *arg)
{ … }
PyDoc_STRVAR(bytearray_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 BYTEARRAY_STRIP_METHODDEF …
static PyObject *
bytearray_strip_impl(PyByteArrayObject *self, PyObject *bytes);
static PyObject *
bytearray_strip(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t nargs)
{ … }
PyDoc_STRVAR(bytearray_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 BYTEARRAY_LSTRIP_METHODDEF …
static PyObject *
bytearray_lstrip_impl(PyByteArrayObject *self, PyObject *bytes);
static PyObject *
bytearray_lstrip(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t nargs)
{ … }
PyDoc_STRVAR(bytearray_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 BYTEARRAY_RSTRIP_METHODDEF …
static PyObject *
bytearray_rstrip_impl(PyByteArrayObject *self, PyObject *bytes);
static PyObject *
bytearray_rstrip(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t nargs)
{ … }
PyDoc_STRVAR(bytearray_decode__doc__,
"decode($self, /, encoding=\'utf-8\', errors=\'strict\')\n"
"--\n"
"\n"
"Decode the bytearray using the codec registered for encoding.\n"
"\n"
" encoding\n"
" The encoding with which to decode the bytearray.\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 BYTEARRAY_DECODE_METHODDEF …
static PyObject *
bytearray_decode_impl(PyByteArrayObject *self, const char *encoding,
const char *errors);
static PyObject *
bytearray_decode(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{ … }
PyDoc_STRVAR(bytearray_join__doc__,
"join($self, iterable_of_bytes, /)\n"
"--\n"
"\n"
"Concatenate any number of bytes/bytearray objects.\n"
"\n"
"The bytearray whose method is called is inserted in between each pair.\n"
"\n"
"The result is returned as a new bytearray object.");
#define BYTEARRAY_JOIN_METHODDEF …
PyDoc_STRVAR(bytearray_splitlines__doc__,
"splitlines($self, /, keepends=False)\n"
"--\n"
"\n"
"Return a list of the lines in the bytearray, breaking at line boundaries.\n"
"\n"
"Line breaks are not included in the resulting list unless keepends is given and\n"
"true.");
#define BYTEARRAY_SPLITLINES_METHODDEF …
static PyObject *
bytearray_splitlines_impl(PyByteArrayObject *self, int keepends);
static PyObject *
bytearray_splitlines(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{ … }
PyDoc_STRVAR(bytearray_fromhex__doc__,
"fromhex($type, string, /)\n"
"--\n"
"\n"
"Create a bytearray object from a string of hexadecimal numbers.\n"
"\n"
"Spaces between two numbers are accepted.\n"
"Example: bytearray.fromhex(\'B9 01EF\') -> bytearray(b\'\\\\xb9\\\\x01\\\\xef\')");
#define BYTEARRAY_FROMHEX_METHODDEF …
static PyObject *
bytearray_fromhex_impl(PyTypeObject *type, PyObject *string);
static PyObject *
bytearray_fromhex(PyTypeObject *type, PyObject *arg)
{ … }
PyDoc_STRVAR(bytearray_hex__doc__,
"hex($self, /, sep=<unrepresentable>, bytes_per_sep=1)\n"
"--\n"
"\n"
"Create a string of hexadecimal numbers from a bytearray object.\n"
"\n"
" sep\n"
" An optional single character or byte to separate hex bytes.\n"
" bytes_per_sep\n"
" How many bytes between separators. Positive values count from the\n"
" right, negative values count from the left.\n"
"\n"
"Example:\n"
">>> value = bytearray([0xb9, 0x01, 0xef])\n"
">>> value.hex()\n"
"\'b901ef\'\n"
">>> value.hex(\':\')\n"
"\'b9:01:ef\'\n"
">>> value.hex(\':\', 2)\n"
"\'b9:01ef\'\n"
">>> value.hex(\':\', -2)\n"
"\'b901:ef\'");
#define BYTEARRAY_HEX_METHODDEF …
static PyObject *
bytearray_hex_impl(PyByteArrayObject *self, PyObject *sep, int bytes_per_sep);
static PyObject *
bytearray_hex(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{ … }
PyDoc_STRVAR(bytearray_reduce__doc__,
"__reduce__($self, /)\n"
"--\n"
"\n"
"Return state information for pickling.");
#define BYTEARRAY_REDUCE_METHODDEF …
static PyObject *
bytearray_reduce_impl(PyByteArrayObject *self);
static PyObject *
bytearray_reduce(PyByteArrayObject *self, PyObject *Py_UNUSED(ignored))
{ … }
PyDoc_STRVAR(bytearray_reduce_ex__doc__,
"__reduce_ex__($self, proto=0, /)\n"
"--\n"
"\n"
"Return state information for pickling.");
#define BYTEARRAY_REDUCE_EX_METHODDEF …
static PyObject *
bytearray_reduce_ex_impl(PyByteArrayObject *self, int proto);
static PyObject *
bytearray_reduce_ex(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t nargs)
{ … }
PyDoc_STRVAR(bytearray_sizeof__doc__,
"__sizeof__($self, /)\n"
"--\n"
"\n"
"Returns the size of the bytearray object in memory, in bytes.");
#define BYTEARRAY_SIZEOF_METHODDEF …
static PyObject *
bytearray_sizeof_impl(PyByteArrayObject *self);
static PyObject *
bytearray_sizeof(PyByteArrayObject *self, PyObject *Py_UNUSED(ignored))
{ … }