#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"
PyDoc_STRVAR(bytes___bytes____doc__,
"__bytes__($self, /)\n"
"--\n"
"\n"
"Convert this value to exact type bytes.");
#define BYTES___BYTES___METHODDEF …
static PyObject *
bytes___bytes___impl(PyBytesObject *self);
static PyObject *
bytes___bytes__(PyBytesObject *self, PyObject *Py_UNUSED(ignored))
{ … }
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 …
static PyObject *
bytes_split_impl(PyBytesObject *self, PyObject *sep, Py_ssize_t maxsplit);
static PyObject *
bytes_split(PyBytesObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{ … }
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 …
static PyObject *
bytes_partition_impl(PyBytesObject *self, Py_buffer *sep);
static PyObject *
bytes_partition(PyBytesObject *self, PyObject *arg)
{ … }
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 at 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 …
static PyObject *
bytes_rpartition_impl(PyBytesObject *self, Py_buffer *sep);
static PyObject *
bytes_rpartition(PyBytesObject *self, PyObject *arg)
{ … }
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 …
static PyObject *
bytes_rsplit_impl(PyBytesObject *self, PyObject *sep, Py_ssize_t maxsplit);
static PyObject *
bytes_rsplit(PyBytesObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{ … }
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 …
PyDoc_STRVAR(bytes_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 BYTES_FIND_METHODDEF …
static PyObject *
bytes_find_impl(PyBytesObject *self, PyObject *sub, Py_ssize_t start,
Py_ssize_t end);
static PyObject *
bytes_find(PyBytesObject *self, PyObject *const *args, Py_ssize_t nargs)
{ … }
PyDoc_STRVAR(bytes_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 BYTES_INDEX_METHODDEF …
static PyObject *
bytes_index_impl(PyBytesObject *self, PyObject *sub, Py_ssize_t start,
Py_ssize_t end);
static PyObject *
bytes_index(PyBytesObject *self, PyObject *const *args, Py_ssize_t nargs)
{ … }
PyDoc_STRVAR(bytes_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 BYTES_RFIND_METHODDEF …
static PyObject *
bytes_rfind_impl(PyBytesObject *self, PyObject *sub, Py_ssize_t start,
Py_ssize_t end);
static PyObject *
bytes_rfind(PyBytesObject *self, PyObject *const *args, Py_ssize_t nargs)
{ … }
PyDoc_STRVAR(bytes_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 BYTES_RINDEX_METHODDEF …
static PyObject *
bytes_rindex_impl(PyBytesObject *self, PyObject *sub, Py_ssize_t start,
Py_ssize_t end);
static PyObject *
bytes_rindex(PyBytesObject *self, PyObject *const *args, Py_ssize_t nargs)
{ … }
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 …
static PyObject *
bytes_strip_impl(PyBytesObject *self, PyObject *bytes);
static PyObject *
bytes_strip(PyBytesObject *self, PyObject *const *args, Py_ssize_t nargs)
{ … }
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 …
static PyObject *
bytes_lstrip_impl(PyBytesObject *self, PyObject *bytes);
static PyObject *
bytes_lstrip(PyBytesObject *self, PyObject *const *args, Py_ssize_t nargs)
{ … }
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 …
static PyObject *
bytes_rstrip_impl(PyBytesObject *self, PyObject *bytes);
static PyObject *
bytes_rstrip(PyBytesObject *self, PyObject *const *args, Py_ssize_t nargs)
{ … }
PyDoc_STRVAR(bytes_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 BYTES_COUNT_METHODDEF …
static PyObject *
bytes_count_impl(PyBytesObject *self, PyObject *sub, Py_ssize_t start,
Py_ssize_t end);
static PyObject *
bytes_count(PyBytesObject *self, PyObject *const *args, Py_ssize_t nargs)
{ … }
PyDoc_STRVAR(bytes_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 BYTES_TRANSLATE_METHODDEF …
static PyObject *
bytes_translate_impl(PyBytesObject *self, PyObject *table,
PyObject *deletechars);
static PyObject *
bytes_translate(PyBytesObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{ … }
PyDoc_STRVAR(bytes_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 BYTES_MAKETRANS_METHODDEF …
static PyObject *
bytes_maketrans_impl(Py_buffer *frm, Py_buffer *to);
static PyObject *
bytes_maketrans(void *null, PyObject *const *args, Py_ssize_t nargs)
{ … }
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 …
static PyObject *
bytes_replace_impl(PyBytesObject *self, Py_buffer *old, Py_buffer *new,
Py_ssize_t count);
static PyObject *
bytes_replace(PyBytesObject *self, PyObject *const *args, Py_ssize_t nargs)
{ … }
PyDoc_STRVAR(bytes_removeprefix__doc__,
"removeprefix($self, prefix, /)\n"
"--\n"
"\n"
"Return a bytes object with the given prefix string removed if present.\n"
"\n"
"If the bytes starts with the prefix string, return bytes[len(prefix):].\n"
"Otherwise, return a copy of the original bytes.");
#define BYTES_REMOVEPREFIX_METHODDEF …
static PyObject *
bytes_removeprefix_impl(PyBytesObject *self, Py_buffer *prefix);
static PyObject *
bytes_removeprefix(PyBytesObject *self, PyObject *arg)
{ … }
PyDoc_STRVAR(bytes_removesuffix__doc__,
"removesuffix($self, suffix, /)\n"
"--\n"
"\n"
"Return a bytes object with the given suffix string removed if present.\n"
"\n"
"If the bytes ends with the suffix string and that suffix is not empty,\n"
"return bytes[:-len(prefix)]. Otherwise, return a copy of the original\n"
"bytes.");
#define BYTES_REMOVESUFFIX_METHODDEF …
static PyObject *
bytes_removesuffix_impl(PyBytesObject *self, Py_buffer *suffix);
static PyObject *
bytes_removesuffix(PyBytesObject *self, PyObject *arg)
{ … }
PyDoc_STRVAR(bytes_startswith__doc__,
"startswith($self, prefix[, start[, end]], /)\n"
"--\n"
"\n"
"Return True if the bytes 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 bytes.\n"
" end\n"
" Optional stop position. Default: end of the bytes.");
#define BYTES_STARTSWITH_METHODDEF …
static PyObject *
bytes_startswith_impl(PyBytesObject *self, PyObject *subobj,
Py_ssize_t start, Py_ssize_t end);
static PyObject *
bytes_startswith(PyBytesObject *self, PyObject *const *args, Py_ssize_t nargs)
{ … }
PyDoc_STRVAR(bytes_endswith__doc__,
"endswith($self, suffix[, start[, end]], /)\n"
"--\n"
"\n"
"Return True if the bytes 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 bytes.\n"
" end\n"
" Optional stop position. Default: end of the bytes.");
#define BYTES_ENDSWITH_METHODDEF …
static PyObject *
bytes_endswith_impl(PyBytesObject *self, PyObject *subobj, Py_ssize_t start,
Py_ssize_t end);
static PyObject *
bytes_endswith(PyBytesObject *self, PyObject *const *args, Py_ssize_t nargs)
{ … }
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 …
static PyObject *
bytes_decode_impl(PyBytesObject *self, const char *encoding,
const char *errors);
static PyObject *
bytes_decode(PyBytesObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{ … }
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 …
static PyObject *
bytes_splitlines_impl(PyBytesObject *self, int keepends);
static PyObject *
bytes_splitlines(PyBytesObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{ … }
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 …
static PyObject *
bytes_fromhex_impl(PyTypeObject *type, PyObject *string);
static PyObject *
bytes_fromhex(PyTypeObject *type, PyObject *arg)
{ … }
PyDoc_STRVAR(bytes_hex__doc__,
"hex($self, /, sep=<unrepresentable>, bytes_per_sep=1)\n"
"--\n"
"\n"
"Create a string of hexadecimal numbers from a bytes 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 = b\'\\xb9\\x01\\xef\'\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 BYTES_HEX_METHODDEF …
static PyObject *
bytes_hex_impl(PyBytesObject *self, PyObject *sep, int bytes_per_sep);
static PyObject *
bytes_hex(PyBytesObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{ … }
static PyObject *
bytes_new_impl(PyTypeObject *type, PyObject *x, const char *encoding,
const char *errors);
static PyObject *
bytes_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
{ … }