summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2009-04-18 15:42:12 (GMT)
committerBenjamin Peterson <benjamin@python.org>2009-04-18 15:42:12 (GMT)
commit153c70f6d770f69314cc3f95ab240e2d9bcaf959 (patch)
tree9244978929836d1cd2f6c1263149b032910f4343 /Objects
parent80688efd6c82a187514a963613fdb1b46bc3cff9 (diff)
downloadcpython-153c70f6d770f69314cc3f95ab240e2d9bcaf959.zip
cpython-153c70f6d770f69314cc3f95ab240e2d9bcaf959.tar.gz
cpython-153c70f6d770f69314cc3f95ab240e2d9bcaf959.tar.bz2
Merged revisions 71719 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r71719 | benjamin.peterson | 2009-04-18 10:31:34 -0500 (Sat, 18 Apr 2009) | 1 line rename internal bytes_ functions to bytearray ........
Diffstat (limited to 'Objects')
-rw-r--r--Objects/bytearrayobject.c292
1 files changed, 146 insertions, 146 deletions
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c
index ca597a2..8daf611 100644
--- a/Objects/bytearrayobject.c
+++ b/Objects/bytearrayobject.c
@@ -57,7 +57,7 @@ _getbytevalue(PyObject* arg, int *value)
}
static int
-bytes_getbuffer(PyByteArrayObject *obj, Py_buffer *view, int flags)
+bytearray_getbuffer(PyByteArrayObject *obj, Py_buffer *view, int flags)
{
int ret;
void *ptr;
@@ -77,7 +77,7 @@ bytes_getbuffer(PyByteArrayObject *obj, Py_buffer *view, int flags)
}
static void
-bytes_releasebuffer(PyByteArrayObject *obj, Py_buffer *view)
+bytearray_releasebuffer(PyByteArrayObject *obj, Py_buffer *view)
{
obj->ob_exports--;
}
@@ -270,13 +270,13 @@ PyByteArray_Concat(PyObject *a, PyObject *b)
/* Functions stuffed into the type object */
static Py_ssize_t
-bytes_length(PyByteArrayObject *self)
+bytearray_length(PyByteArrayObject *self)
{
return Py_SIZE(self);
}
static PyObject *
-bytes_iconcat(PyByteArrayObject *self, PyObject *other)
+bytearray_iconcat(PyByteArrayObject *self, PyObject *other)
{
Py_ssize_t mysize;
Py_ssize_t size;
@@ -309,7 +309,7 @@ bytes_iconcat(PyByteArrayObject *self, PyObject *other)
}
static PyObject *
-bytes_repeat(PyByteArrayObject *self, Py_ssize_t count)
+bytearray_repeat(PyByteArrayObject *self, Py_ssize_t count)
{
PyByteArrayObject *result;
Py_ssize_t mysize;
@@ -335,7 +335,7 @@ bytes_repeat(PyByteArrayObject *self, Py_ssize_t count)
}
static PyObject *
-bytes_irepeat(PyByteArrayObject *self, Py_ssize_t count)
+bytearray_irepeat(PyByteArrayObject *self, Py_ssize_t count)
{
Py_ssize_t mysize;
Py_ssize_t size;
@@ -366,7 +366,7 @@ bytes_irepeat(PyByteArrayObject *self, Py_ssize_t count)
}
static PyObject *
-bytes_getitem(PyByteArrayObject *self, Py_ssize_t i)
+bytearray_getitem(PyByteArrayObject *self, Py_ssize_t i)
{
if (i < 0)
i += Py_SIZE(self);
@@ -378,7 +378,7 @@ bytes_getitem(PyByteArrayObject *self, Py_ssize_t i)
}
static PyObject *
-bytes_subscript(PyByteArrayObject *self, PyObject *index)
+bytearray_subscript(PyByteArrayObject *self, PyObject *index)
{
if (PyIndex_Check(index)) {
Py_ssize_t i = PyNumber_AsSsize_t(index, PyExc_IndexError);
@@ -433,7 +433,7 @@ bytes_subscript(PyByteArrayObject *self, PyObject *index)
}
static int
-bytes_setslice(PyByteArrayObject *self, Py_ssize_t lo, Py_ssize_t hi,
+bytearray_setslice(PyByteArrayObject *self, Py_ssize_t lo, Py_ssize_t hi,
PyObject *values)
{
Py_ssize_t avail, needed;
@@ -448,7 +448,7 @@ bytes_setslice(PyByteArrayObject *self, Py_ssize_t lo, Py_ssize_t hi,
values = PyByteArray_FromObject(values);
if (values == NULL)
return -1;
- err = bytes_setslice(self, lo, hi, values);
+ err = bytearray_setslice(self, lo, hi, values);
Py_DECREF(values);
return err;
}
@@ -523,7 +523,7 @@ bytes_setslice(PyByteArrayObject *self, Py_ssize_t lo, Py_ssize_t hi,
}
static int
-bytes_setitem(PyByteArrayObject *self, Py_ssize_t i, PyObject *value)
+bytearray_setitem(PyByteArrayObject *self, Py_ssize_t i, PyObject *value)
{
int ival;
@@ -536,7 +536,7 @@ bytes_setitem(PyByteArrayObject *self, Py_ssize_t i, PyObject *value)
}
if (value == NULL)
- return bytes_setslice(self, i, i+1, NULL);
+ return bytearray_setslice(self, i, i+1, NULL);
if (!_getbytevalue(value, &ival))
return -1;
@@ -546,7 +546,7 @@ bytes_setitem(PyByteArrayObject *self, Py_ssize_t i, PyObject *value)
}
static int
-bytes_ass_subscript(PyByteArrayObject *self, PyObject *index, PyObject *values)
+bytearray_ass_subscript(PyByteArrayObject *self, PyObject *index, PyObject *values)
{
Py_ssize_t start, stop, step, slicelen, needed;
char *bytes;
@@ -602,7 +602,7 @@ bytes_ass_subscript(PyByteArrayObject *self, PyObject *index, PyObject *values)
values = PyByteArray_FromObject(values);
if (values == NULL)
return -1;
- err = bytes_ass_subscript(self, index, values);
+ err = bytearray_ass_subscript(self, index, values);
Py_DECREF(values);
return err;
}
@@ -703,7 +703,7 @@ bytes_ass_subscript(PyByteArrayObject *self, PyObject *index, PyObject *values)
}
static int
-bytes_init(PyByteArrayObject *self, PyObject *args, PyObject *kwds)
+bytearray_init(PyByteArrayObject *self, PyObject *args, PyObject *kwds)
{
static char *kwlist[] = {"source", "encoding", "errors", 0};
PyObject *arg = NULL;
@@ -746,7 +746,7 @@ bytes_init(PyByteArrayObject *self, PyObject *args, PyObject *kwds)
if (encoded == NULL)
return -1;
assert(PyBytes_Check(encoded));
- new = bytes_iconcat(self, encoded);
+ new = bytearray_iconcat(self, encoded);
Py_DECREF(encoded);
if (new == NULL)
return -1;
@@ -846,7 +846,7 @@ bytes_init(PyByteArrayObject *self, PyObject *args, PyObject *kwds)
/* Mostly copied from string_repr, but without the
"smart quote" functionality. */
static PyObject *
-bytes_repr(PyByteArrayObject *self)
+bytearray_repr(PyByteArrayObject *self)
{
static const char *hexdigits = "0123456789abcdef";
const char *quote_prefix = "bytearray(b";
@@ -931,18 +931,18 @@ bytes_repr(PyByteArrayObject *self)
}
static PyObject *
-bytes_str(PyObject *op)
+bytearray_str(PyObject *op)
{
if (Py_BytesWarningFlag) {
if (PyErr_WarnEx(PyExc_BytesWarning,
"str() on a bytearray instance", 1))
return NULL;
}
- return bytes_repr((PyByteArrayObject*)op);
+ return bytearray_repr((PyByteArrayObject*)op);
}
static PyObject *
-bytes_richcompare(PyObject *self, PyObject *other, int op)
+bytearray_richcompare(PyObject *self, PyObject *other, int op)
{
Py_ssize_t self_size, other_size;
Py_buffer self_bytes, other_bytes;
@@ -1017,7 +1017,7 @@ bytes_richcompare(PyObject *self, PyObject *other, int op)
}
static void
-bytes_dealloc(PyByteArrayObject *self)
+bytearray_dealloc(PyByteArrayObject *self)
{
if (self->ob_exports > 0) {
PyErr_SetString(PyExc_SystemError,
@@ -1072,7 +1072,7 @@ _adjust_indices(Py_ssize_t *start, Py_ssize_t *end, Py_ssize_t len)
Py_LOCAL_INLINE(Py_ssize_t)
-bytes_find_internal(PyByteArrayObject *self, PyObject *args, int dir)
+bytearray_find_internal(PyByteArrayObject *self, PyObject *args, int dir)
{
PyObject *subobj;
Py_buffer subbuf;
@@ -1106,9 +1106,9 @@ arguments start and end are interpreted as in slice notation.\n\
Return -1 on failure.");
static PyObject *
-bytes_find(PyByteArrayObject *self, PyObject *args)
+bytearray_find(PyByteArrayObject *self, PyObject *args)
{
- Py_ssize_t result = bytes_find_internal(self, args, +1);
+ Py_ssize_t result = bytearray_find_internal(self, args, +1);
if (result == -2)
return NULL;
return PyLong_FromSsize_t(result);
@@ -1122,7 +1122,7 @@ bytes B[start:end]. Optional arguments start and end are interpreted\n\
as in slice notation.");
static PyObject *
-bytes_count(PyByteArrayObject *self, PyObject *args)
+bytearray_count(PyByteArrayObject *self, PyObject *args)
{
PyObject *sub_obj;
const char *str = PyByteArray_AS_STRING(self);
@@ -1153,9 +1153,9 @@ PyDoc_STRVAR(index__doc__,
Like B.find() but raise ValueError when the subsection is not found.");
static PyObject *
-bytes_index(PyByteArrayObject *self, PyObject *args)
+bytearray_index(PyByteArrayObject *self, PyObject *args)
{
- Py_ssize_t result = bytes_find_internal(self, args, +1);
+ Py_ssize_t result = bytearray_find_internal(self, args, +1);
if (result == -2)
return NULL;
if (result == -1) {
@@ -1177,9 +1177,9 @@ arguments start and end are interpreted as in slice notation.\n\
Return -1 on failure.");
static PyObject *
-bytes_rfind(PyByteArrayObject *self, PyObject *args)
+bytearray_rfind(PyByteArrayObject *self, PyObject *args)
{
- Py_ssize_t result = bytes_find_internal(self, args, -1);
+ Py_ssize_t result = bytearray_find_internal(self, args, -1);
if (result == -2)
return NULL;
return PyLong_FromSsize_t(result);
@@ -1192,9 +1192,9 @@ PyDoc_STRVAR(rindex__doc__,
Like B.rfind() but raise ValueError when the subsection is not found.");
static PyObject *
-bytes_rindex(PyByteArrayObject *self, PyObject *args)
+bytearray_rindex(PyByteArrayObject *self, PyObject *args)
{
- Py_ssize_t result = bytes_find_internal(self, args, -1);
+ Py_ssize_t result = bytearray_find_internal(self, args, -1);
if (result == -2)
return NULL;
if (result == -1) {
@@ -1207,7 +1207,7 @@ bytes_rindex(PyByteArrayObject *self, PyObject *args)
static int
-bytes_contains(PyObject *self, PyObject *arg)
+bytearray_contains(PyObject *self, PyObject *arg)
{
Py_ssize_t ival = PyNumber_AsSsize_t(arg, PyExc_ValueError);
if (ival == -1 && PyErr_Occurred()) {
@@ -1235,7 +1235,7 @@ bytes_contains(PyObject *self, PyObject *arg)
* -1 on error, 0 if not found and 1 if found.
*/
Py_LOCAL(int)
-_bytes_tailmatch(PyByteArrayObject *self, PyObject *substr, Py_ssize_t start,
+_bytearray_tailmatch(PyByteArrayObject *self, PyObject *substr, Py_ssize_t start,
Py_ssize_t end, int direction)
{
Py_ssize_t len = PyByteArray_GET_SIZE(self);
@@ -1282,7 +1282,7 @@ With optional end, stop comparing B at that position.\n\
prefix can also be a tuple of strings to try.");
static PyObject *
-bytes_startswith(PyByteArrayObject *self, PyObject *args)
+bytearray_startswith(PyByteArrayObject *self, PyObject *args)
{
Py_ssize_t start = 0;
Py_ssize_t end = PY_SSIZE_T_MAX;
@@ -1295,7 +1295,7 @@ bytes_startswith(PyByteArrayObject *self, PyObject *args)
if (PyTuple_Check(subobj)) {
Py_ssize_t i;
for (i = 0; i < PyTuple_GET_SIZE(subobj); i++) {
- result = _bytes_tailmatch(self,
+ result = _bytearray_tailmatch(self,
PyTuple_GET_ITEM(subobj, i),
start, end, -1);
if (result == -1)
@@ -1306,7 +1306,7 @@ bytes_startswith(PyByteArrayObject *self, PyObject *args)
}
Py_RETURN_FALSE;
}
- result = _bytes_tailmatch(self, subobj, start, end, -1);
+ result = _bytearray_tailmatch(self, subobj, start, end, -1);
if (result == -1)
return NULL;
else
@@ -1322,7 +1322,7 @@ With optional end, stop comparing B at that position.\n\
suffix can also be a tuple of strings to try.");
static PyObject *
-bytes_endswith(PyByteArrayObject *self, PyObject *args)
+bytearray_endswith(PyByteArrayObject *self, PyObject *args)
{
Py_ssize_t start = 0;
Py_ssize_t end = PY_SSIZE_T_MAX;
@@ -1335,7 +1335,7 @@ bytes_endswith(PyByteArrayObject *self, PyObject *args)
if (PyTuple_Check(subobj)) {
Py_ssize_t i;
for (i = 0; i < PyTuple_GET_SIZE(subobj); i++) {
- result = _bytes_tailmatch(self,
+ result = _bytearray_tailmatch(self,
PyTuple_GET_ITEM(subobj, i),
start, end, +1);
if (result == -1)
@@ -1346,7 +1346,7 @@ bytes_endswith(PyByteArrayObject *self, PyObject *args)
}
Py_RETURN_FALSE;
}
- result = _bytes_tailmatch(self, subobj, start, end, +1);
+ result = _bytearray_tailmatch(self, subobj, start, end, +1);
if (result == -1)
return NULL;
else
@@ -1363,7 +1363,7 @@ characters have been mapped through the given translation\n\
table, which must be a bytes object of length 256.");
static PyObject *
-bytes_translate(PyByteArrayObject *self, PyObject *args)
+bytearray_translate(PyByteArrayObject *self, PyObject *args)
{
register char *input, *output;
register const char *table;
@@ -1452,7 +1452,7 @@ done:
static PyObject *
-bytes_maketrans(PyObject *null, PyObject *args)
+bytearray_maketrans(PyObject *null, PyObject *args)
{
return _Py_bytes_maketrans(args);
}
@@ -2059,7 +2059,7 @@ old replaced by new. If the optional argument count is\n\
given, only the first count occurrences are replaced.");
static PyObject *
-bytes_replace(PyByteArrayObject *self, PyObject *args)
+bytearray_replace(PyByteArrayObject *self, PyObject *args)
{
Py_ssize_t count = -1;
PyObject *from, *to, *res;
@@ -2210,7 +2210,7 @@ If sep is not given, B is split on ASCII whitespace characters\n\
If maxsplit is given, at most maxsplit splits are done.");
static PyObject *
-bytes_split(PyByteArrayObject *self, PyObject *args)
+bytearray_split(PyByteArrayObject *self, PyObject *args)
{
Py_ssize_t len = PyByteArray_GET_SIZE(self), n, i, j;
Py_ssize_t maxsplit = -1, count = 0;
@@ -2317,7 +2317,7 @@ the separator itself, and the part after it. If the separator is not\n\
found, returns B and two empty bytearray objects.");
static PyObject *
-bytes_partition(PyByteArrayObject *self, PyObject *sep_obj)
+bytearray_partition(PyByteArrayObject *self, PyObject *sep_obj)
{
PyObject *bytesep, *result;
@@ -2345,7 +2345,7 @@ part after it. If the separator is not found, returns two empty\n\
bytearray objects and B.");
static PyObject *
-bytes_rpartition(PyByteArrayObject *self, PyObject *sep_obj)
+bytearray_rpartition(PyByteArrayObject *self, PyObject *sep_obj)
{
PyObject *bytesep, *result;
@@ -2448,7 +2448,7 @@ If sep is not given, B is split on ASCII whitespace characters\n\
If maxsplit is given, at most maxsplit splits are done.");
static PyObject *
-bytes_rsplit(PyByteArrayObject *self, PyObject *args)
+bytearray_rsplit(PyByteArrayObject *self, PyObject *args)
{
Py_ssize_t len = PyByteArray_GET_SIZE(self), n, i, j;
Py_ssize_t maxsplit = -1, count = 0;
@@ -2517,7 +2517,7 @@ PyDoc_STRVAR(reverse__doc__,
\n\
Reverse the order of the values in B in place.");
static PyObject *
-bytes_reverse(PyByteArrayObject *self, PyObject *unused)
+bytearray_reverse(PyByteArrayObject *self, PyObject *unused)
{
char swap, *head, *tail;
Py_ssize_t i, j, n = Py_SIZE(self);
@@ -2539,7 +2539,7 @@ PyDoc_STRVAR(insert__doc__,
\n\
Insert a single item into the bytearray before the given index.");
static PyObject *
-bytes_insert(PyByteArrayObject *self, PyObject *args)
+bytearray_insert(PyByteArrayObject *self, PyObject *args)
{
PyObject *value;
int ival;
@@ -2576,7 +2576,7 @@ PyDoc_STRVAR(append__doc__,
\n\
Append a single item to the end of B.");
static PyObject *
-bytes_append(PyByteArrayObject *self, PyObject *arg)
+bytearray_append(PyByteArrayObject *self, PyObject *arg)
{
int value;
Py_ssize_t n = Py_SIZE(self);
@@ -2602,16 +2602,16 @@ PyDoc_STRVAR(extend__doc__,
Append all the elements from the iterator or sequence to the\n\
end of B.");
static PyObject *
-bytes_extend(PyByteArrayObject *self, PyObject *arg)
+bytearray_extend(PyByteArrayObject *self, PyObject *arg)
{
- PyObject *it, *item, *bytes_obj;
+ PyObject *it, *item, *bytearray_obj;
Py_ssize_t buf_size = 0, len = 0;
int value;
char *buf;
- /* bytes_setslice code only accepts something supporting PEP 3118. */
+ /* bytearray_setslice code only accepts something supporting PEP 3118. */
if (PyObject_CheckBuffer(arg)) {
- if (bytes_setslice(self, Py_SIZE(self), Py_SIZE(self), arg) == -1)
+ if (bytearray_setslice(self, Py_SIZE(self), Py_SIZE(self), arg) == -1)
return NULL;
Py_RETURN_NONE;
@@ -2628,16 +2628,16 @@ bytes_extend(PyByteArrayObject *self, PyObject *arg)
return NULL;
}
- bytes_obj = PyByteArray_FromStringAndSize(NULL, buf_size);
- if (bytes_obj == NULL)
+ bytearray_obj = PyByteArray_FromStringAndSize(NULL, buf_size);
+ if (bytearray_obj == NULL)
return NULL;
- buf = PyByteArray_AS_STRING(bytes_obj);
+ buf = PyByteArray_AS_STRING(bytearray_obj);
while ((item = PyIter_Next(it)) != NULL) {
if (! _getbytevalue(item, &value)) {
Py_DECREF(item);
Py_DECREF(it);
- Py_DECREF(bytes_obj);
+ Py_DECREF(bytearray_obj);
return NULL;
}
buf[len++] = value;
@@ -2645,27 +2645,27 @@ bytes_extend(PyByteArrayObject *self, PyObject *arg)
if (len >= buf_size) {
buf_size = len + (len >> 1) + 1;
- if (PyByteArray_Resize((PyObject *)bytes_obj, buf_size) < 0) {
+ if (PyByteArray_Resize((PyObject *)bytearray_obj, buf_size) < 0) {
Py_DECREF(it);
- Py_DECREF(bytes_obj);
+ Py_DECREF(bytearray_obj);
return NULL;
}
/* Recompute the `buf' pointer, since the resizing operation may
have invalidated it. */
- buf = PyByteArray_AS_STRING(bytes_obj);
+ buf = PyByteArray_AS_STRING(bytearray_obj);
}
}
Py_DECREF(it);
/* Resize down to exact size. */
- if (PyByteArray_Resize((PyObject *)bytes_obj, len) < 0) {
- Py_DECREF(bytes_obj);
+ if (PyByteArray_Resize((PyObject *)bytearray_obj, len) < 0) {
+ Py_DECREF(bytearray_obj);
return NULL;
}
- if (bytes_setslice(self, Py_SIZE(self), Py_SIZE(self), bytes_obj) == -1)
+ if (bytearray_setslice(self, Py_SIZE(self), Py_SIZE(self), bytearray_obj) == -1)
return NULL;
- Py_DECREF(bytes_obj);
+ Py_DECREF(bytearray_obj);
Py_RETURN_NONE;
}
@@ -2676,7 +2676,7 @@ PyDoc_STRVAR(pop__doc__,
Remove and return a single item from B. If no index\n\
argument is given, will pop the last value.");
static PyObject *
-bytes_pop(PyByteArrayObject *self, PyObject *args)
+bytearray_pop(PyByteArrayObject *self, PyObject *args)
{
int value;
Py_ssize_t where = -1, n = Py_SIZE(self);
@@ -2711,7 +2711,7 @@ PyDoc_STRVAR(remove__doc__,
\n\
Remove the first occurrence of a value in B.");
static PyObject *
-bytes_remove(PyByteArrayObject *self, PyObject *arg)
+bytearray_remove(PyByteArrayObject *self, PyObject *arg)
{
int value;
Py_ssize_t where, n = Py_SIZE(self);
@@ -2766,7 +2766,7 @@ Strip leading and trailing bytes contained in the argument\n\
and return the result as a new bytearray.\n\
If the argument is omitted, strip ASCII whitespace.");
static PyObject *
-bytes_strip(PyByteArrayObject *self, PyObject *args)
+bytearray_strip(PyByteArrayObject *self, PyObject *args)
{
Py_ssize_t left, right, mysize, argsize;
void *myptr, *argptr;
@@ -2803,7 +2803,7 @@ Strip leading bytes contained in the argument\n\
and return the result as a new bytearray.\n\
If the argument is omitted, strip leading ASCII whitespace.");
static PyObject *
-bytes_lstrip(PyByteArrayObject *self, PyObject *args)
+bytearray_lstrip(PyByteArrayObject *self, PyObject *args)
{
Py_ssize_t left, right, mysize, argsize;
void *myptr, *argptr;
@@ -2837,7 +2837,7 @@ Strip trailing bytes contained in the argument\n\
and return the result as a new bytearray.\n\
If the argument is omitted, strip trailing ASCII whitespace.");
static PyObject *
-bytes_rstrip(PyByteArrayObject *self, PyObject *args)
+bytearray_rstrip(PyByteArrayObject *self, PyObject *args)
{
Py_ssize_t left, right, mysize, argsize;
void *myptr, *argptr;
@@ -2875,7 +2875,7 @@ as well as any other name registered with codecs.register_error that is\n\
able to handle UnicodeDecodeErrors.");
static PyObject *
-bytes_decode(PyObject *self, PyObject *args)
+bytearray_decode(PyObject *self, PyObject *args)
{
const char *encoding = NULL;
const char *errors = NULL;
@@ -2893,7 +2893,7 @@ PyDoc_STRVAR(alloc_doc,
Return the number of bytes actually allocated.");
static PyObject *
-bytes_alloc(PyByteArrayObject *self)
+bytearray_alloc(PyByteArrayObject *self)
{
return PyLong_FromSsize_t(self->ob_alloc);
}
@@ -2905,7 +2905,7 @@ Concatenate any number of bytes/bytearray objects, with B\n\
in between each pair, and return the result as a new bytearray.");
static PyObject *
-bytes_join(PyByteArrayObject *self, PyObject *it)
+bytearray_join(PyByteArrayObject *self, PyObject *it)
{
PyObject *seq;
Py_ssize_t mysize = Py_SIZE(self);
@@ -2998,7 +2998,7 @@ hex_digit_to_int(Py_UNICODE c)
}
static PyObject *
-bytes_fromhex(PyObject *cls, PyObject *args)
+bytearray_fromhex(PyObject *cls, PyObject *args)
{
PyObject *newbytes, *hexobj;
char *buf;
@@ -3044,7 +3044,7 @@ bytes_fromhex(PyObject *cls, PyObject *args)
PyDoc_STRVAR(reduce_doc, "Return state information for pickling.");
static PyObject *
-bytes_reduce(PyByteArrayObject *self)
+bytearray_reduce(PyByteArrayObject *self)
{
PyObject *latin1, *dict;
if (self->ob_bytes)
@@ -3068,7 +3068,7 @@ PyDoc_STRVAR(sizeof_doc,
\n\
Returns the size of B in memory, in bytes");
static PyObject *
-bytes_sizeof(PyByteArrayObject *self)
+bytearray_sizeof(PyByteArrayObject *self)
{
Py_ssize_t res;
@@ -3076,50 +3076,50 @@ bytes_sizeof(PyByteArrayObject *self)
return PyLong_FromSsize_t(res);
}
-static PySequenceMethods bytes_as_sequence = {
- (lenfunc)bytes_length, /* sq_length */
+static PySequenceMethods bytearray_as_sequence = {
+ (lenfunc)bytearray_length, /* sq_length */
(binaryfunc)PyByteArray_Concat, /* sq_concat */
- (ssizeargfunc)bytes_repeat, /* sq_repeat */
- (ssizeargfunc)bytes_getitem, /* sq_item */
- 0, /* sq_slice */
- (ssizeobjargproc)bytes_setitem, /* sq_ass_item */
- 0, /* sq_ass_slice */
- (objobjproc)bytes_contains, /* sq_contains */
- (binaryfunc)bytes_iconcat, /* sq_inplace_concat */
- (ssizeargfunc)bytes_irepeat, /* sq_inplace_repeat */
+ (ssizeargfunc)bytearray_repeat, /* sq_repeat */
+ (ssizeargfunc)bytearray_getitem, /* sq_item */
+ 0, /* sq_slice */
+ (ssizeobjargproc)bytearray_setitem, /* sq_ass_item */
+ 0, /* sq_ass_slice */
+ (objobjproc)bytearray_contains, /* sq_contains */
+ (binaryfunc)bytearray_iconcat, /* sq_inplace_concat */
+ (ssizeargfunc)bytearray_irepeat, /* sq_inplace_repeat */
};
-static PyMappingMethods bytes_as_mapping = {
- (lenfunc)bytes_length,
- (binaryfunc)bytes_subscript,
- (objobjargproc)bytes_ass_subscript,
+static PyMappingMethods bytearray_as_mapping = {
+ (lenfunc)bytearray_length,
+ (binaryfunc)bytearray_subscript,
+ (objobjargproc)bytearray_ass_subscript,
};
-static PyBufferProcs bytes_as_buffer = {
- (getbufferproc)bytes_getbuffer,
- (releasebufferproc)bytes_releasebuffer,
+static PyBufferProcs bytearray_as_buffer = {
+ (getbufferproc)bytearray_getbuffer,
+ (releasebufferproc)bytearray_releasebuffer,
};
static PyMethodDef
-bytes_methods[] = {
- {"__alloc__", (PyCFunction)bytes_alloc, METH_NOARGS, alloc_doc},
- {"__reduce__", (PyCFunction)bytes_reduce, METH_NOARGS, reduce_doc},
- {"__sizeof__", (PyCFunction)bytes_sizeof, METH_NOARGS, sizeof_doc},
- {"append", (PyCFunction)bytes_append, METH_O, append__doc__},
+bytearray_methods[] = {
+ {"__alloc__", (PyCFunction)bytearray_alloc, METH_NOARGS, alloc_doc},
+ {"__reduce__", (PyCFunction)bytearray_reduce, METH_NOARGS, reduce_doc},
+ {"__sizeof__", (PyCFunction)bytearray_sizeof, METH_NOARGS, sizeof_doc},
+ {"append", (PyCFunction)bytearray_append, METH_O, append__doc__},
{"capitalize", (PyCFunction)stringlib_capitalize, METH_NOARGS,
_Py_capitalize__doc__},
{"center", (PyCFunction)stringlib_center, METH_VARARGS, center__doc__},
- {"count", (PyCFunction)bytes_count, METH_VARARGS, count__doc__},
- {"decode", (PyCFunction)bytes_decode, METH_VARARGS, decode_doc},
- {"endswith", (PyCFunction)bytes_endswith, METH_VARARGS, endswith__doc__},
+ {"count", (PyCFunction)bytearray_count, METH_VARARGS, count__doc__},
+ {"decode", (PyCFunction)bytearray_decode, METH_VARARGS, decode_doc},
+ {"endswith", (PyCFunction)bytearray_endswith, METH_VARARGS, endswith__doc__},
{"expandtabs", (PyCFunction)stringlib_expandtabs, METH_VARARGS,
expandtabs__doc__},
- {"extend", (PyCFunction)bytes_extend, METH_O, extend__doc__},
- {"find", (PyCFunction)bytes_find, METH_VARARGS, find__doc__},
- {"fromhex", (PyCFunction)bytes_fromhex, METH_VARARGS|METH_CLASS,
+ {"extend", (PyCFunction)bytearray_extend, METH_O, extend__doc__},
+ {"find", (PyCFunction)bytearray_find, METH_VARARGS, find__doc__},
+ {"fromhex", (PyCFunction)bytearray_fromhex, METH_VARARGS|METH_CLASS,
fromhex_doc},
- {"index", (PyCFunction)bytes_index, METH_VARARGS, index__doc__},
- {"insert", (PyCFunction)bytes_insert, METH_VARARGS, insert__doc__},
+ {"index", (PyCFunction)bytearray_index, METH_VARARGS, index__doc__},
+ {"insert", (PyCFunction)bytearray_insert, METH_VARARGS, insert__doc__},
{"isalnum", (PyCFunction)stringlib_isalnum, METH_NOARGS,
_Py_isalnum__doc__},
{"isalpha", (PyCFunction)stringlib_isalpha, METH_NOARGS,
@@ -3134,40 +3134,40 @@ bytes_methods[] = {
_Py_istitle__doc__},
{"isupper", (PyCFunction)stringlib_isupper, METH_NOARGS,
_Py_isupper__doc__},
- {"join", (PyCFunction)bytes_join, METH_O, join_doc},
+ {"join", (PyCFunction)bytearray_join, METH_O, join_doc},
{"ljust", (PyCFunction)stringlib_ljust, METH_VARARGS, ljust__doc__},
{"lower", (PyCFunction)stringlib_lower, METH_NOARGS, _Py_lower__doc__},
- {"lstrip", (PyCFunction)bytes_lstrip, METH_VARARGS, lstrip__doc__},
- {"maketrans", (PyCFunction)bytes_maketrans, METH_VARARGS|METH_STATIC,
+ {"lstrip", (PyCFunction)bytearray_lstrip, METH_VARARGS, lstrip__doc__},
+ {"maketrans", (PyCFunction)bytearray_maketrans, METH_VARARGS|METH_STATIC,
_Py_maketrans__doc__},
- {"partition", (PyCFunction)bytes_partition, METH_O, partition__doc__},
- {"pop", (PyCFunction)bytes_pop, METH_VARARGS, pop__doc__},
- {"remove", (PyCFunction)bytes_remove, METH_O, remove__doc__},
- {"replace", (PyCFunction)bytes_replace, METH_VARARGS, replace__doc__},
- {"reverse", (PyCFunction)bytes_reverse, METH_NOARGS, reverse__doc__},
- {"rfind", (PyCFunction)bytes_rfind, METH_VARARGS, rfind__doc__},
- {"rindex", (PyCFunction)bytes_rindex, METH_VARARGS, rindex__doc__},
+ {"partition", (PyCFunction)bytearray_partition, METH_O, partition__doc__},
+ {"pop", (PyCFunction)bytearray_pop, METH_VARARGS, pop__doc__},
+ {"remove", (PyCFunction)bytearray_remove, METH_O, remove__doc__},
+ {"replace", (PyCFunction)bytearray_replace, METH_VARARGS, replace__doc__},
+ {"reverse", (PyCFunction)bytearray_reverse, METH_NOARGS, reverse__doc__},
+ {"rfind", (PyCFunction)bytearray_rfind, METH_VARARGS, rfind__doc__},
+ {"rindex", (PyCFunction)bytearray_rindex, METH_VARARGS, rindex__doc__},
{"rjust", (PyCFunction)stringlib_rjust, METH_VARARGS, rjust__doc__},
- {"rpartition", (PyCFunction)bytes_rpartition, METH_O, rpartition__doc__},
- {"rsplit", (PyCFunction)bytes_rsplit, METH_VARARGS, rsplit__doc__},
- {"rstrip", (PyCFunction)bytes_rstrip, METH_VARARGS, rstrip__doc__},
- {"split", (PyCFunction)bytes_split, METH_VARARGS, split__doc__},
+ {"rpartition", (PyCFunction)bytearray_rpartition, METH_O, rpartition__doc__},
+ {"rsplit", (PyCFunction)bytearray_rsplit, METH_VARARGS, rsplit__doc__},
+ {"rstrip", (PyCFunction)bytearray_rstrip, METH_VARARGS, rstrip__doc__},
+ {"split", (PyCFunction)bytearray_split, METH_VARARGS, split__doc__},
{"splitlines", (PyCFunction)stringlib_splitlines, METH_VARARGS,
splitlines__doc__},
- {"startswith", (PyCFunction)bytes_startswith, METH_VARARGS ,
+ {"startswith", (PyCFunction)bytearray_startswith, METH_VARARGS ,
startswith__doc__},
- {"strip", (PyCFunction)bytes_strip, METH_VARARGS, strip__doc__},
+ {"strip", (PyCFunction)bytearray_strip, METH_VARARGS, strip__doc__},
{"swapcase", (PyCFunction)stringlib_swapcase, METH_NOARGS,
_Py_swapcase__doc__},
{"title", (PyCFunction)stringlib_title, METH_NOARGS, _Py_title__doc__},
- {"translate", (PyCFunction)bytes_translate, METH_VARARGS,
+ {"translate", (PyCFunction)bytearray_translate, METH_VARARGS,
translate__doc__},
{"upper", (PyCFunction)stringlib_upper, METH_NOARGS, _Py_upper__doc__},
{"zfill", (PyCFunction)stringlib_zfill, METH_VARARGS, zfill__doc__},
{NULL}
};
-PyDoc_STRVAR(bytes_doc,
+PyDoc_STRVAR(bytearray_doc,
"bytearray(iterable_of_ints) -> bytearray\n\
bytearray(string, encoding[, errors]) -> bytearray\n\
bytearray(bytes_or_bytearray) -> mutable copy of bytes_or_bytearray\n\
@@ -3184,37 +3184,37 @@ bytearray(int) -> bytearray\n\
Construct a zero-initialized bytearray of the given length.");
-static PyObject *bytes_iter(PyObject *seq);
+static PyObject *bytearray_iter(PyObject *seq);
PyTypeObject PyByteArray_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"bytearray",
sizeof(PyByteArrayObject),
0,
- (destructor)bytes_dealloc, /* tp_dealloc */
+ (destructor)bytearray_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_reserved */
- (reprfunc)bytes_repr, /* tp_repr */
+ (reprfunc)bytearray_repr, /* tp_repr */
0, /* tp_as_number */
- &bytes_as_sequence, /* tp_as_sequence */
- &bytes_as_mapping, /* tp_as_mapping */
+ &bytearray_as_sequence, /* tp_as_sequence */
+ &bytearray_as_mapping, /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
- bytes_str, /* tp_str */
+ bytearray_str, /* tp_str */
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
- &bytes_as_buffer, /* tp_as_buffer */
+ &bytearray_as_buffer, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- bytes_doc, /* tp_doc */
+ bytearray_doc, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
- (richcmpfunc)bytes_richcompare, /* tp_richcompare */
+ (richcmpfunc)bytearray_richcompare, /* tp_richcompare */
0, /* tp_weaklistoffset */
- bytes_iter, /* tp_iter */
+ bytearray_iter, /* tp_iter */
0, /* tp_iternext */
- bytes_methods, /* tp_methods */
+ bytearray_methods, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
@@ -3222,7 +3222,7 @@ PyTypeObject PyByteArray_Type = {
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
- (initproc)bytes_init, /* tp_init */
+ (initproc)bytearray_init, /* tp_init */
PyType_GenericAlloc, /* tp_alloc */
PyType_GenericNew, /* tp_new */
PyObject_Del, /* tp_free */
@@ -3237,7 +3237,7 @@ typedef struct {
} bytesiterobject;
static void
-bytesiter_dealloc(bytesiterobject *it)
+bytearrayiter_dealloc(bytesiterobject *it)
{
_PyObject_GC_UNTRACK(it);
Py_XDECREF(it->it_seq);
@@ -3245,14 +3245,14 @@ bytesiter_dealloc(bytesiterobject *it)
}
static int
-bytesiter_traverse(bytesiterobject *it, visitproc visit, void *arg)
+bytearrayiter_traverse(bytesiterobject *it, visitproc visit, void *arg)
{
Py_VISIT(it->it_seq);
return 0;
}
static PyObject *
-bytesiter_next(bytesiterobject *it)
+bytearrayiter_next(bytesiterobject *it)
{
PyByteArrayObject *seq;
PyObject *item;
@@ -3277,7 +3277,7 @@ bytesiter_next(bytesiterobject *it)
}
static PyObject *
-bytesiter_length_hint(bytesiterobject *it)
+bytesarrayiter_length_hint(bytesiterobject *it)
{
Py_ssize_t len = 0;
if (it->it_seq)
@@ -3288,8 +3288,8 @@ bytesiter_length_hint(bytesiterobject *it)
PyDoc_STRVAR(length_hint_doc,
"Private method returning an estimate of len(list(it)).");
-static PyMethodDef bytesiter_methods[] = {
- {"__length_hint__", (PyCFunction)bytesiter_length_hint, METH_NOARGS,
+static PyMethodDef bytearrayiter_methods[] = {
+ {"__length_hint__", (PyCFunction)bytesarrayiter_length_hint, METH_NOARGS,
length_hint_doc},
{NULL, NULL} /* sentinel */
};
@@ -3300,7 +3300,7 @@ PyTypeObject PyByteArrayIter_Type = {
sizeof(bytesiterobject), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
- (destructor)bytesiter_dealloc, /* tp_dealloc */
+ (destructor)bytearrayiter_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
@@ -3317,18 +3317,18 @@ PyTypeObject PyByteArrayIter_Type = {
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
0, /* tp_doc */
- (traverseproc)bytesiter_traverse, /* tp_traverse */
+ (traverseproc)bytearrayiter_traverse, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
PyObject_SelfIter, /* tp_iter */
- (iternextfunc)bytesiter_next, /* tp_iternext */
- bytesiter_methods, /* tp_methods */
+ (iternextfunc)bytearrayiter_next, /* tp_iternext */
+ bytearrayiter_methods, /* tp_methods */
0,
};
static PyObject *
-bytes_iter(PyObject *seq)
+bytearray_iter(PyObject *seq)
{
bytesiterobject *it;