diff options
author | Christian Heimes <christian@cheimes.de> | 2008-05-26 13:22:05 (GMT) |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2008-05-26 13:22:05 (GMT) |
commit | 9c4756ea265b5ebd71c9ae59f3673c7cecb6f060 (patch) | |
tree | 642b21e774a9cb2d949e10ce65e7d10326c70138 /Objects | |
parent | 96d02f3c1e145821cd5ce8817d4263e7d8d57e4a (diff) | |
download | cpython-9c4756ea265b5ebd71c9ae59f3673c7cecb6f060.zip cpython-9c4756ea265b5ebd71c9ae59f3673c7cecb6f060.tar.gz cpython-9c4756ea265b5ebd71c9ae59f3673c7cecb6f060.tar.bz2 |
Renamed PyBytes to PyByteArray
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/bytesobject.c | 466 | ||||
-rw-r--r-- | Objects/longobject.c | 6 | ||||
-rw-r--r-- | Objects/memoryobject.c | 12 | ||||
-rw-r--r-- | Objects/object.c | 2 | ||||
-rw-r--r-- | Objects/stringobject.c | 6 | ||||
-rw-r--r-- | Objects/unicodeobject.c | 62 |
6 files changed, 277 insertions, 277 deletions
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c index 385429c..98dc0f7 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -1,22 +1,22 @@ -/* PyBytes (bytearray) implementation */ +/* PyByteArray (bytearray) implementation */ #define PY_SSIZE_T_CLEAN #include "Python.h" #include "structmember.h" #include "bytes_methods.h" -static PyBytesObject *nullbytes = NULL; +static PyByteArrayObject *nullbytes = NULL; void -PyBytes_Fini(void) +PyByteArray_Fini(void) { Py_CLEAR(nullbytes); } int -PyBytes_Init(void) +PyByteArray_Init(void) { - nullbytes = PyObject_New(PyBytesObject, &PyBytes_Type); + nullbytes = PyObject_New(PyByteArrayObject, &PyByteArray_Type); if (nullbytes == NULL) return 0; nullbytes->ob_bytes = NULL; @@ -50,7 +50,7 @@ _getbytevalue(PyObject* arg, int *value) } static int -bytes_getbuffer(PyBytesObject *obj, Py_buffer *view, int flags) +bytes_getbuffer(PyByteArrayObject *obj, Py_buffer *view, int flags) { int ret; void *ptr; @@ -70,7 +70,7 @@ bytes_getbuffer(PyBytesObject *obj, Py_buffer *view, int flags) } static void -bytes_releasebuffer(PyBytesObject *obj, Py_buffer *view) +bytes_releasebuffer(PyByteArrayObject *obj, Py_buffer *view) { obj->ob_exports--; } @@ -96,25 +96,25 @@ _getbuffer(PyObject *obj, Py_buffer *view) /* Direct API functions */ PyObject * -PyBytes_FromObject(PyObject *input) +PyByteArray_FromObject(PyObject *input) { - return PyObject_CallFunctionObjArgs((PyObject *)&PyBytes_Type, + return PyObject_CallFunctionObjArgs((PyObject *)&PyByteArray_Type, input, NULL); } PyObject * -PyBytes_FromStringAndSize(const char *bytes, Py_ssize_t size) +PyByteArray_FromStringAndSize(const char *bytes, Py_ssize_t size) { - PyBytesObject *new; + PyByteArrayObject *new; Py_ssize_t alloc; if (size < 0) { PyErr_SetString(PyExc_SystemError, - "Negative size passed to PyBytes_FromStringAndSize"); + "Negative size passed to PyByteArray_FromStringAndSize"); return NULL; } - new = PyObject_New(PyBytesObject, &PyBytes_Type); + new = PyObject_New(PyByteArrayObject, &PyByteArray_Type); if (new == NULL) return NULL; @@ -141,31 +141,31 @@ PyBytes_FromStringAndSize(const char *bytes, Py_ssize_t size) } Py_ssize_t -PyBytes_Size(PyObject *self) +PyByteArray_Size(PyObject *self) { assert(self != NULL); - assert(PyBytes_Check(self)); + assert(PyByteArray_Check(self)); - return PyBytes_GET_SIZE(self); + return PyByteArray_GET_SIZE(self); } char * -PyBytes_AsString(PyObject *self) +PyByteArray_AsString(PyObject *self) { assert(self != NULL); - assert(PyBytes_Check(self)); + assert(PyByteArray_Check(self)); - return PyBytes_AS_STRING(self); + return PyByteArray_AS_STRING(self); } int -PyBytes_Resize(PyObject *self, Py_ssize_t size) +PyByteArray_Resize(PyObject *self, Py_ssize_t size) { void *sval; - Py_ssize_t alloc = ((PyBytesObject *)self)->ob_alloc; + Py_ssize_t alloc = ((PyByteArrayObject *)self)->ob_alloc; assert(self != NULL); - assert(PyBytes_Check(self)); + assert(PyByteArray_Check(self)); assert(size >= 0); if (size < alloc / 2) { @@ -175,7 +175,7 @@ PyBytes_Resize(PyObject *self, Py_ssize_t size) else if (size < alloc) { /* Within allocated size; quick exit */ Py_SIZE(self) = size; - ((PyBytesObject *)self)->ob_bytes[size] = '\0'; /* Trailing null */ + ((PyByteArrayObject *)self)->ob_bytes[size] = '\0'; /* Trailing null */ return 0; } else if (size <= alloc * 1.125) { @@ -187,36 +187,36 @@ PyBytes_Resize(PyObject *self, Py_ssize_t size) alloc = size + 1; } - if (((PyBytesObject *)self)->ob_exports > 0) { + if (((PyByteArrayObject *)self)->ob_exports > 0) { /* - fprintf(stderr, "%d: %s", ((PyBytesObject *)self)->ob_exports, - ((PyBytesObject *)self)->ob_bytes); + fprintf(stderr, "%d: %s", ((PyByteArrayObject *)self)->ob_exports, + ((PyByteArrayObject *)self)->ob_bytes); */ PyErr_SetString(PyExc_BufferError, "Existing exports of data: object cannot be re-sized"); return -1; } - sval = PyMem_Realloc(((PyBytesObject *)self)->ob_bytes, alloc); + sval = PyMem_Realloc(((PyByteArrayObject *)self)->ob_bytes, alloc); if (sval == NULL) { PyErr_NoMemory(); return -1; } - ((PyBytesObject *)self)->ob_bytes = sval; + ((PyByteArrayObject *)self)->ob_bytes = sval; Py_SIZE(self) = size; - ((PyBytesObject *)self)->ob_alloc = alloc; - ((PyBytesObject *)self)->ob_bytes[size] = '\0'; /* Trailing null byte */ + ((PyByteArrayObject *)self)->ob_alloc = alloc; + ((PyByteArrayObject *)self)->ob_bytes[size] = '\0'; /* Trailing null byte */ return 0; } PyObject * -PyBytes_Concat(PyObject *a, PyObject *b) +PyByteArray_Concat(PyObject *a, PyObject *b) { Py_ssize_t size; Py_buffer va, vb; - PyBytesObject *result = NULL; + PyByteArrayObject *result = NULL; va.len = -1; vb.len = -1; @@ -233,7 +233,7 @@ PyBytes_Concat(PyObject *a, PyObject *b) goto done; } - result = (PyBytesObject *) PyBytes_FromStringAndSize(NULL, size); + result = (PyByteArrayObject *) PyByteArray_FromStringAndSize(NULL, size); if (result != NULL) { memcpy(result->ob_bytes, va.buf, va.len); memcpy(result->ob_bytes + va.len, vb.buf, vb.len); @@ -250,13 +250,13 @@ PyBytes_Concat(PyObject *a, PyObject *b) /* Functions stuffed into the type object */ static Py_ssize_t -bytes_length(PyBytesObject *self) +bytes_length(PyByteArrayObject *self) { return Py_SIZE(self); } static PyObject * -bytes_iconcat(PyBytesObject *self, PyObject *other) +bytes_iconcat(PyByteArrayObject *self, PyObject *other) { Py_ssize_t mysize; Py_ssize_t size; @@ -278,7 +278,7 @@ bytes_iconcat(PyBytesObject *self, PyObject *other) Py_SIZE(self) = size; self->ob_bytes[Py_SIZE(self)] = '\0'; /* Trailing null byte */ } - else if (PyBytes_Resize((PyObject *)self, size) < 0) { + else if (PyByteArray_Resize((PyObject *)self, size) < 0) { PyObject_ReleaseBuffer(other, &vo); return NULL; } @@ -289,9 +289,9 @@ bytes_iconcat(PyBytesObject *self, PyObject *other) } static PyObject * -bytes_repeat(PyBytesObject *self, Py_ssize_t count) +bytes_repeat(PyByteArrayObject *self, Py_ssize_t count) { - PyBytesObject *result; + PyByteArrayObject *result; Py_ssize_t mysize; Py_ssize_t size; @@ -301,7 +301,7 @@ bytes_repeat(PyBytesObject *self, Py_ssize_t count) size = mysize * count; if (count != 0 && size / count != mysize) return PyErr_NoMemory(); - result = (PyBytesObject *)PyBytes_FromStringAndSize(NULL, size); + result = (PyByteArrayObject *)PyByteArray_FromStringAndSize(NULL, size); if (result != NULL && size != 0) { if (mysize == 1) memset(result->ob_bytes, self->ob_bytes[0], size); @@ -315,7 +315,7 @@ bytes_repeat(PyBytesObject *self, Py_ssize_t count) } static PyObject * -bytes_irepeat(PyBytesObject *self, Py_ssize_t count) +bytes_irepeat(PyByteArrayObject *self, Py_ssize_t count) { Py_ssize_t mysize; Py_ssize_t size; @@ -330,7 +330,7 @@ bytes_irepeat(PyBytesObject *self, Py_ssize_t count) Py_SIZE(self) = size; self->ob_bytes[Py_SIZE(self)] = '\0'; /* Trailing null byte */ } - else if (PyBytes_Resize((PyObject *)self, size) < 0) + else if (PyByteArray_Resize((PyObject *)self, size) < 0) return NULL; if (mysize == 1) @@ -346,7 +346,7 @@ bytes_irepeat(PyBytesObject *self, Py_ssize_t count) } static PyObject * -bytes_getitem(PyBytesObject *self, Py_ssize_t i) +bytes_getitem(PyByteArrayObject *self, Py_ssize_t i) { if (i < 0) i += Py_SIZE(self); @@ -358,7 +358,7 @@ bytes_getitem(PyBytesObject *self, Py_ssize_t i) } static PyObject * -bytes_subscript(PyBytesObject *self, PyObject *item) +bytes_subscript(PyByteArrayObject *self, PyObject *item) { if (PyIndex_Check(item)) { Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError); @@ -367,7 +367,7 @@ bytes_subscript(PyBytesObject *self, PyObject *item) return NULL; if (i < 0) - i += PyBytes_GET_SIZE(self); + i += PyByteArray_GET_SIZE(self); if (i < 0 || i >= Py_SIZE(self)) { PyErr_SetString(PyExc_IndexError, "bytearray index out of range"); @@ -378,19 +378,19 @@ bytes_subscript(PyBytesObject *self, PyObject *item) else if (PySlice_Check(item)) { Py_ssize_t start, stop, step, slicelength, cur, i; if (PySlice_GetIndicesEx((PySliceObject *)item, - PyBytes_GET_SIZE(self), + PyByteArray_GET_SIZE(self), &start, &stop, &step, &slicelength) < 0) { return NULL; } if (slicelength <= 0) - return PyBytes_FromStringAndSize("", 0); + return PyByteArray_FromStringAndSize("", 0); else if (step == 1) { - return PyBytes_FromStringAndSize(self->ob_bytes + start, + return PyByteArray_FromStringAndSize(self->ob_bytes + start, slicelength); } else { - char *source_buf = PyBytes_AS_STRING(self); + char *source_buf = PyByteArray_AS_STRING(self); char *result_buf = (char *)PyMem_Malloc(slicelength); PyObject *result; @@ -401,7 +401,7 @@ bytes_subscript(PyBytesObject *self, PyObject *item) cur += step, i++) { result_buf[i] = source_buf[cur]; } - result = PyBytes_FromStringAndSize(result_buf, slicelength); + result = PyByteArray_FromStringAndSize(result_buf, slicelength); PyMem_Free(result_buf); return result; } @@ -413,7 +413,7 @@ bytes_subscript(PyBytesObject *self, PyObject *item) } static int -bytes_setslice(PyBytesObject *self, Py_ssize_t lo, Py_ssize_t hi, +bytes_setslice(PyByteArrayObject *self, Py_ssize_t lo, Py_ssize_t hi, PyObject *values) { Py_ssize_t avail, needed; @@ -425,7 +425,7 @@ bytes_setslice(PyBytesObject *self, Py_ssize_t lo, Py_ssize_t hi, if (values == (PyObject *)self) { /* Make a copy and call this function recursively */ int err; - values = PyBytes_FromObject(values); + values = PyByteArray_FromObject(values); if (values == NULL) return -1; err = bytes_setslice(self, lo, hi, values); @@ -471,7 +471,7 @@ bytes_setslice(PyBytesObject *self, Py_ssize_t lo, Py_ssize_t hi, Py_SIZE(self) - hi); } /* XXX(nnorwitz): need to verify this can't overflow! */ - if (PyBytes_Resize((PyObject *)self, + if (PyByteArray_Resize((PyObject *)self, Py_SIZE(self) + needed - avail) < 0) { res = -1; goto finish; @@ -499,7 +499,7 @@ bytes_setslice(PyBytesObject *self, Py_ssize_t lo, Py_ssize_t hi, } static int -bytes_setitem(PyBytesObject *self, Py_ssize_t i, PyObject *value) +bytes_setitem(PyByteArrayObject *self, Py_ssize_t i, PyObject *value) { Py_ssize_t ival; @@ -528,7 +528,7 @@ bytes_setitem(PyBytesObject *self, Py_ssize_t i, PyObject *value) } static int -bytes_ass_subscript(PyBytesObject *self, PyObject *item, PyObject *values) +bytes_ass_subscript(PyByteArrayObject *self, PyObject *item, PyObject *values) { Py_ssize_t start, stop, step, slicelen, needed; char *bytes; @@ -540,7 +540,7 @@ bytes_ass_subscript(PyBytesObject *self, PyObject *item, PyObject *values) return -1; if (i < 0) - i += PyBytes_GET_SIZE(self); + i += PyByteArray_GET_SIZE(self); if (i < 0 || i >= Py_SIZE(self)) { PyErr_SetString(PyExc_IndexError, "bytearray index out of range"); @@ -569,7 +569,7 @@ bytes_ass_subscript(PyBytesObject *self, PyObject *item, PyObject *values) } else if (PySlice_Check(item)) { if (PySlice_GetIndicesEx((PySliceObject *)item, - PyBytes_GET_SIZE(self), + PyByteArray_GET_SIZE(self), &start, &stop, &step, &slicelen) < 0) { return -1; } @@ -583,10 +583,10 @@ bytes_ass_subscript(PyBytesObject *self, PyObject *item, PyObject *values) bytes = NULL; needed = 0; } - else if (values == (PyObject *)self || !PyBytes_Check(values)) { + else if (values == (PyObject *)self || !PyByteArray_Check(values)) { /* Make a copy an call this function recursively */ int err; - values = PyBytes_FromObject(values); + values = PyByteArray_FromObject(values); if (values == NULL) return -1; err = bytes_ass_subscript(self, item, values); @@ -594,8 +594,8 @@ bytes_ass_subscript(PyBytesObject *self, PyObject *item, PyObject *values) return err; } else { - assert(PyBytes_Check(values)); - bytes = ((PyBytesObject *)values)->ob_bytes; + assert(PyByteArray_Check(values)); + bytes = ((PyByteArrayObject *)values)->ob_bytes; needed = Py_SIZE(values); } /* Make sure b[5:2] = ... inserts before 5, not before 2. */ @@ -614,7 +614,7 @@ bytes_ass_subscript(PyBytesObject *self, PyObject *item, PyObject *values) memmove(self->ob_bytes + start + needed, self->ob_bytes + stop, Py_SIZE(self) - stop); } - if (PyBytes_Resize((PyObject *)self, + if (PyByteArray_Resize((PyObject *)self, Py_SIZE(self) + needed - slicelen) < 0) return -1; if (slicelen < needed) { @@ -648,21 +648,21 @@ bytes_ass_subscript(PyBytesObject *self, PyObject *item, PyObject *values) i < slicelen; cur += step, i++) { Py_ssize_t lim = step - 1; - if (cur + step >= PyBytes_GET_SIZE(self)) - lim = PyBytes_GET_SIZE(self) - cur - 1; + if (cur + step >= PyByteArray_GET_SIZE(self)) + lim = PyByteArray_GET_SIZE(self) - cur - 1; memmove(self->ob_bytes + cur - i, self->ob_bytes + cur + 1, lim); } /* Move the tail of the bytes, in one chunk */ cur = start + slicelen*step; - if (cur < PyBytes_GET_SIZE(self)) { + if (cur < PyByteArray_GET_SIZE(self)) { memmove(self->ob_bytes + cur - slicelen, self->ob_bytes + cur, - PyBytes_GET_SIZE(self) - cur); + PyByteArray_GET_SIZE(self) - cur); } - if (PyBytes_Resize((PyObject *)self, - PyBytes_GET_SIZE(self) - slicelen) < 0) + if (PyByteArray_Resize((PyObject *)self, + PyByteArray_GET_SIZE(self) - slicelen) < 0) return -1; return 0; @@ -686,7 +686,7 @@ bytes_ass_subscript(PyBytesObject *self, PyObject *item, PyObject *values) } static int -bytes_init(PyBytesObject *self, PyObject *args, PyObject *kwds) +bytes_init(PyByteArrayObject *self, PyObject *args, PyObject *kwds) { static char *kwlist[] = {"source", "encoding", "errors", 0}; PyObject *arg = NULL; @@ -698,7 +698,7 @@ bytes_init(PyBytesObject *self, PyObject *args, PyObject *kwds) if (Py_SIZE(self) != 0) { /* Empty previous contents (yes, do this first of all!) */ - if (PyBytes_Resize((PyObject *)self, 0) < 0) + if (PyByteArray_Resize((PyObject *)self, 0) < 0) return -1; } @@ -754,7 +754,7 @@ bytes_init(PyBytesObject *self, PyObject *args, PyObject *kwds) return -1; } if (count > 0) { - if (PyBytes_Resize((PyObject *)self, count)) + if (PyByteArray_Resize((PyObject *)self, count)) return -1; memset(self->ob_bytes, 0, count); } @@ -768,7 +768,7 @@ bytes_init(PyBytesObject *self, PyObject *args, PyObject *kwds) if (PyObject_GetBuffer(arg, &view, PyBUF_FULL_RO) < 0) return -1; size = view.len; - if (PyBytes_Resize((PyObject *)self, size) < 0) goto fail; + if (PyByteArray_Resize((PyObject *)self, size) < 0) goto fail; if (PyBuffer_ToContiguous(self->ob_bytes, &view, size, 'C') < 0) goto fail; PyObject_ReleaseBuffer(arg, &view); @@ -818,7 +818,7 @@ bytes_init(PyBytesObject *self, PyObject *args, PyObject *kwds) /* Append the byte */ if (Py_SIZE(self) < self->ob_alloc) Py_SIZE(self)++; - else if (PyBytes_Resize((PyObject *)self, Py_SIZE(self)+1) < 0) + else if (PyByteArray_Resize((PyObject *)self, Py_SIZE(self)+1) < 0) goto error; self->ob_bytes[Py_SIZE(self)-1] = value; } @@ -836,7 +836,7 @@ bytes_init(PyBytesObject *self, PyObject *args, PyObject *kwds) /* Mostly copied from string_repr, but without the "smart quote" functionality. */ static PyObject * -bytes_repr(PyBytesObject *self) +bytes_repr(PyByteArrayObject *self) { static const char *hexdigits = "0123456789abcdef"; const char *quote_prefix = "bytearray(b"; @@ -864,7 +864,7 @@ bytes_repr(PyBytesObject *self) quote = '\''; { char *test, *start; - start = PyBytes_AS_STRING(self); + start = PyByteArray_AS_STRING(self); for (test = start; test < start+length; ++test) { if (*test == '"') { quote = '\''; /* back to single */ @@ -928,7 +928,7 @@ bytes_str(PyObject *op) "str() on a bytearray instance", 1)) return NULL; } - return bytes_repr((PyBytesObject*)op); + return bytes_repr((PyByteArrayObject*)op); } static PyObject * @@ -1007,7 +1007,7 @@ bytes_richcompare(PyObject *self, PyObject *other, int op) } static void -bytes_dealloc(PyBytesObject *self) +bytes_dealloc(PyByteArrayObject *self) { if (self->ob_bytes != 0) { PyMem_Free(self->ob_bytes); @@ -1021,11 +1021,11 @@ bytes_dealloc(PyBytesObject *self) #define STRINGLIB_CHAR char #define STRINGLIB_CMP memcmp -#define STRINGLIB_LEN PyBytes_GET_SIZE -#define STRINGLIB_STR PyBytes_AS_STRING -#define STRINGLIB_NEW PyBytes_FromStringAndSize +#define STRINGLIB_LEN PyByteArray_GET_SIZE +#define STRINGLIB_STR PyByteArray_AS_STRING +#define STRINGLIB_NEW PyByteArray_FromStringAndSize #define STRINGLIB_EMPTY nullbytes -#define STRINGLIB_CHECK_EXACT PyBytes_CheckExact +#define STRINGLIB_CHECK_EXACT PyByteArray_CheckExact #define STRINGLIB_MUTABLE 1 #include "stringlib/fastsearch.h" @@ -1056,7 +1056,7 @@ _adjust_indices(Py_ssize_t *start, Py_ssize_t *end, Py_ssize_t len) Py_LOCAL_INLINE(Py_ssize_t) -bytes_find_internal(PyBytesObject *self, PyObject *args, int dir) +bytes_find_internal(PyByteArrayObject *self, PyObject *args, int dir) { PyObject *subobj; Py_buffer subbuf; @@ -1070,11 +1070,11 @@ bytes_find_internal(PyBytesObject *self, PyObject *args, int dir) return -2; if (dir > 0) res = stringlib_find_slice( - PyBytes_AS_STRING(self), PyBytes_GET_SIZE(self), + PyByteArray_AS_STRING(self), PyByteArray_GET_SIZE(self), subbuf.buf, subbuf.len, start, end); else res = stringlib_rfind_slice( - PyBytes_AS_STRING(self), PyBytes_GET_SIZE(self), + PyByteArray_AS_STRING(self), PyByteArray_GET_SIZE(self), subbuf.buf, subbuf.len, start, end); PyObject_ReleaseBuffer(subobj, &subbuf); return res; @@ -1090,7 +1090,7 @@ arguments start and end are interpreted as in slice notation.\n\ Return -1 on failure."); static PyObject * -bytes_find(PyBytesObject *self, PyObject *args) +bytes_find(PyByteArrayObject *self, PyObject *args) { Py_ssize_t result = bytes_find_internal(self, args, +1); if (result == -2) @@ -1106,10 +1106,10 @@ bytes B[start:end]. Optional arguments start and end are interpreted\n\ as in slice notation."); static PyObject * -bytes_count(PyBytesObject *self, PyObject *args) +bytes_count(PyByteArrayObject *self, PyObject *args) { PyObject *sub_obj; - const char *str = PyBytes_AS_STRING(self); + const char *str = PyByteArray_AS_STRING(self); Py_ssize_t start = 0, end = PY_SSIZE_T_MAX; Py_buffer vsub; PyObject *count_obj; @@ -1121,7 +1121,7 @@ bytes_count(PyBytesObject *self, PyObject *args) if (_getbuffer(sub_obj, &vsub) < 0) return NULL; - _adjust_indices(&start, &end, PyBytes_GET_SIZE(self)); + _adjust_indices(&start, &end, PyByteArray_GET_SIZE(self)); count_obj = PyLong_FromSsize_t( stringlib_count(str + start, end - start, vsub.buf, vsub.len) @@ -1137,7 +1137,7 @@ PyDoc_STRVAR(index__doc__, Like B.find() but raise ValueError when the subsection is not found."); static PyObject * -bytes_index(PyBytesObject *self, PyObject *args) +bytes_index(PyByteArrayObject *self, PyObject *args) { Py_ssize_t result = bytes_find_internal(self, args, +1); if (result == -2) @@ -1161,7 +1161,7 @@ arguments start and end are interpreted as in slice notation.\n\ Return -1 on failure."); static PyObject * -bytes_rfind(PyBytesObject *self, PyObject *args) +bytes_rfind(PyByteArrayObject *self, PyObject *args) { Py_ssize_t result = bytes_find_internal(self, args, -1); if (result == -2) @@ -1176,7 +1176,7 @@ PyDoc_STRVAR(rindex__doc__, Like B.rfind() but raise ValueError when the subsection is not found."); static PyObject * -bytes_rindex(PyBytesObject *self, PyObject *args) +bytes_rindex(PyByteArrayObject *self, PyObject *args) { Py_ssize_t result = bytes_find_internal(self, args, -1); if (result == -2) @@ -1200,7 +1200,7 @@ bytes_contains(PyObject *self, PyObject *arg) PyErr_Clear(); if (_getbuffer(arg, &varg) < 0) return -1; - pos = stringlib_find(PyBytes_AS_STRING(self), Py_SIZE(self), + pos = stringlib_find(PyByteArray_AS_STRING(self), Py_SIZE(self), varg.buf, varg.len, 0); PyObject_ReleaseBuffer(arg, &varg); return pos >= 0; @@ -1210,7 +1210,7 @@ bytes_contains(PyObject *self, PyObject *arg) return -1; } - return memchr(PyBytes_AS_STRING(self), ival, Py_SIZE(self)) != NULL; + return memchr(PyByteArray_AS_STRING(self), ival, Py_SIZE(self)) != NULL; } @@ -1219,15 +1219,15 @@ bytes_contains(PyObject *self, PyObject *arg) * -1 on error, 0 if not found and 1 if found. */ Py_LOCAL(int) -_bytes_tailmatch(PyBytesObject *self, PyObject *substr, Py_ssize_t start, +_bytes_tailmatch(PyByteArrayObject *self, PyObject *substr, Py_ssize_t start, Py_ssize_t end, int direction) { - Py_ssize_t len = PyBytes_GET_SIZE(self); + Py_ssize_t len = PyByteArray_GET_SIZE(self); const char* str; Py_buffer vsubstr; int rv = 0; - str = PyBytes_AS_STRING(self); + str = PyByteArray_AS_STRING(self); if (_getbuffer(substr, &vsubstr) < 0) return -1; @@ -1266,7 +1266,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(PyBytesObject *self, PyObject *args) +bytes_startswith(PyByteArrayObject *self, PyObject *args) { Py_ssize_t start = 0; Py_ssize_t end = PY_SSIZE_T_MAX; @@ -1306,7 +1306,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(PyBytesObject *self, PyObject *args) +bytes_endswith(PyByteArrayObject *self, PyObject *args) { Py_ssize_t start = 0; Py_ssize_t end = PY_SSIZE_T_MAX; @@ -1347,7 +1347,7 @@ characters have been mapped through the given translation\n\ table, which must be a bytes object of length 256."); static PyObject * -bytes_translate(PyBytesObject *self, PyObject *args) +bytes_translate(PyByteArrayObject *self, PyObject *args) { register char *input, *output; register const char *table; @@ -1386,12 +1386,12 @@ bytes_translate(PyBytesObject *self, PyObject *args) } table = (const char *)vtable.buf; - inlen = PyBytes_GET_SIZE(input_obj); - result = PyBytes_FromStringAndSize((char *)NULL, inlen); + inlen = PyByteArray_GET_SIZE(input_obj); + result = PyByteArray_FromStringAndSize((char *)NULL, inlen); if (result == NULL) goto done; - output_start = output = PyBytes_AsString(result); - input = PyBytes_AS_STRING(input_obj); + output_start = output = PyByteArray_AsString(result); + input = PyByteArray_AS_STRING(input_obj); if (vdel.len == 0) { /* If no deletions are required, use faster code */ @@ -1400,7 +1400,7 @@ bytes_translate(PyBytesObject *self, PyObject *args) if (Py_CHARMASK((*output++ = table[c])) != c) changed = 1; } - if (changed || !PyBytes_CheckExact(input_obj)) + if (changed || !PyByteArray_CheckExact(input_obj)) goto done; Py_DECREF(result); Py_INCREF(input_obj); @@ -1421,7 +1421,7 @@ bytes_translate(PyBytesObject *self, PyObject *args) continue; changed = 1; } - if (!changed && PyBytes_CheckExact(input_obj)) { + if (!changed && PyByteArray_CheckExact(input_obj)) { Py_DECREF(result); Py_INCREF(input_obj); result = input_obj; @@ -1429,7 +1429,7 @@ bytes_translate(PyBytesObject *self, PyObject *args) } /* Fix the size of the resulting string */ if (inlen > 0) - PyBytes_Resize(result, output - output_start); + PyByteArray_Resize(result, output - output_start); done: PyObject_ReleaseBuffer(tableobj, &vtable); @@ -1456,16 +1456,16 @@ done: /* Bytes ops must return a string. */ /* If the object is subclass of bytes, create a copy */ -Py_LOCAL(PyBytesObject *) -return_self(PyBytesObject *self) +Py_LOCAL(PyByteArrayObject *) +return_self(PyByteArrayObject *self) { - if (PyBytes_CheckExact(self)) { + if (PyByteArray_CheckExact(self)) { Py_INCREF(self); - return (PyBytesObject *)self; + return (PyByteArrayObject *)self; } - return (PyBytesObject *)PyBytes_FromStringAndSize( - PyBytes_AS_STRING(self), - PyBytes_GET_SIZE(self)); + return (PyByteArrayObject *)PyByteArray_FromStringAndSize( + PyByteArray_AS_STRING(self), + PyByteArray_GET_SIZE(self)); } Py_LOCAL_INLINE(Py_ssize_t) @@ -1575,17 +1575,17 @@ countstring(const char *target, Py_ssize_t target_len, /* Algorithms for different cases of string replacement */ /* len(self)>=1, from="", len(to)>=1, maxcount>=1 */ -Py_LOCAL(PyBytesObject *) -replace_interleave(PyBytesObject *self, +Py_LOCAL(PyByteArrayObject *) +replace_interleave(PyByteArrayObject *self, const char *to_s, Py_ssize_t to_len, Py_ssize_t maxcount) { char *self_s, *result_s; Py_ssize_t self_len, result_len; Py_ssize_t count, i, product; - PyBytesObject *result; + PyByteArrayObject *result; - self_len = PyBytes_GET_SIZE(self); + self_len = PyByteArray_GET_SIZE(self); /* 1 at the end plus 1 after every character */ count = self_len+1; @@ -1607,12 +1607,12 @@ replace_interleave(PyBytesObject *self, return NULL; } - if (! (result = (PyBytesObject *) - PyBytes_FromStringAndSize(NULL, result_len)) ) + if (! (result = (PyByteArrayObject *) + PyByteArray_FromStringAndSize(NULL, result_len)) ) return NULL; - self_s = PyBytes_AS_STRING(self); - result_s = PyBytes_AS_STRING(result); + self_s = PyByteArray_AS_STRING(self); + result_s = PyByteArray_AS_STRING(result); /* TODO: special case single character, which doesn't need memcpy */ @@ -1635,18 +1635,18 @@ replace_interleave(PyBytesObject *self, /* Special case for deleting a single character */ /* len(self)>=1, len(from)==1, to="", maxcount>=1 */ -Py_LOCAL(PyBytesObject *) -replace_delete_single_character(PyBytesObject *self, +Py_LOCAL(PyByteArrayObject *) +replace_delete_single_character(PyByteArrayObject *self, char from_c, Py_ssize_t maxcount) { char *self_s, *result_s; char *start, *next, *end; Py_ssize_t self_len, result_len; Py_ssize_t count; - PyBytesObject *result; + PyByteArrayObject *result; - self_len = PyBytes_GET_SIZE(self); - self_s = PyBytes_AS_STRING(self); + self_len = PyByteArray_GET_SIZE(self); + self_s = PyByteArray_AS_STRING(self); count = countchar(self_s, self_len, from_c, maxcount); if (count == 0) { @@ -1656,10 +1656,10 @@ replace_delete_single_character(PyBytesObject *self, result_len = self_len - count; /* from_len == 1 */ assert(result_len>=0); - if ( (result = (PyBytesObject *) - PyBytes_FromStringAndSize(NULL, result_len)) == NULL) + if ( (result = (PyByteArrayObject *) + PyByteArray_FromStringAndSize(NULL, result_len)) == NULL) return NULL; - result_s = PyBytes_AS_STRING(result); + result_s = PyByteArray_AS_STRING(result); start = self_s; end = self_s + self_len; @@ -1678,8 +1678,8 @@ replace_delete_single_character(PyBytesObject *self, /* len(self)>=1, len(from)>=2, to="", maxcount>=1 */ -Py_LOCAL(PyBytesObject *) -replace_delete_substring(PyBytesObject *self, +Py_LOCAL(PyByteArrayObject *) +replace_delete_substring(PyByteArrayObject *self, const char *from_s, Py_ssize_t from_len, Py_ssize_t maxcount) { @@ -1687,10 +1687,10 @@ replace_delete_substring(PyBytesObject *self, char *start, *next, *end; Py_ssize_t self_len, result_len; Py_ssize_t count, offset; - PyBytesObject *result; + PyByteArrayObject *result; - self_len = PyBytes_GET_SIZE(self); - self_s = PyBytes_AS_STRING(self); + self_len = PyByteArray_GET_SIZE(self); + self_s = PyByteArray_AS_STRING(self); count = countstring(self_s, self_len, from_s, from_len, @@ -1705,11 +1705,11 @@ replace_delete_substring(PyBytesObject *self, result_len = self_len - (count * from_len); assert (result_len>=0); - if ( (result = (PyBytesObject *) - PyBytes_FromStringAndSize(NULL, result_len)) == NULL ) + if ( (result = (PyByteArrayObject *) + PyByteArray_FromStringAndSize(NULL, result_len)) == NULL ) return NULL; - result_s = PyBytes_AS_STRING(result); + result_s = PyByteArray_AS_STRING(result); start = self_s; end = self_s + self_len; @@ -1731,18 +1731,18 @@ replace_delete_substring(PyBytesObject *self, } /* len(self)>=1, len(from)==len(to)==1, maxcount>=1 */ -Py_LOCAL(PyBytesObject *) -replace_single_character_in_place(PyBytesObject *self, +Py_LOCAL(PyByteArrayObject *) +replace_single_character_in_place(PyByteArrayObject *self, char from_c, char to_c, Py_ssize_t maxcount) { char *self_s, *result_s, *start, *end, *next; Py_ssize_t self_len; - PyBytesObject *result; + PyByteArrayObject *result; /* The result string will be the same size */ - self_s = PyBytes_AS_STRING(self); - self_len = PyBytes_GET_SIZE(self); + self_s = PyByteArray_AS_STRING(self); + self_len = PyByteArray_GET_SIZE(self); next = findchar(self_s, self_len, from_c); @@ -1752,10 +1752,10 @@ replace_single_character_in_place(PyBytesObject *self, } /* Need to make a new bytes */ - result = (PyBytesObject *) PyBytes_FromStringAndSize(NULL, self_len); + result = (PyByteArrayObject *) PyByteArray_FromStringAndSize(NULL, self_len); if (result == NULL) return NULL; - result_s = PyBytes_AS_STRING(result); + result_s = PyByteArray_AS_STRING(result); Py_MEMCPY(result_s, self_s, self_len); /* change everything in-place, starting with this one */ @@ -1776,8 +1776,8 @@ replace_single_character_in_place(PyBytesObject *self, } /* len(self)>=1, len(from)==len(to)>=2, maxcount>=1 */ -Py_LOCAL(PyBytesObject *) -replace_substring_in_place(PyBytesObject *self, +Py_LOCAL(PyByteArrayObject *) +replace_substring_in_place(PyByteArrayObject *self, const char *from_s, Py_ssize_t from_len, const char *to_s, Py_ssize_t to_len, Py_ssize_t maxcount) @@ -1785,12 +1785,12 @@ replace_substring_in_place(PyBytesObject *self, char *result_s, *start, *end; char *self_s; Py_ssize_t self_len, offset; - PyBytesObject *result; + PyByteArrayObject *result; /* The result bytes will be the same size */ - self_s = PyBytes_AS_STRING(self); - self_len = PyBytes_GET_SIZE(self); + self_s = PyByteArray_AS_STRING(self); + self_len = PyByteArray_GET_SIZE(self); offset = findstring(self_s, self_len, from_s, from_len, @@ -1801,10 +1801,10 @@ replace_substring_in_place(PyBytesObject *self, } /* Need to make a new bytes */ - result = (PyBytesObject *) PyBytes_FromStringAndSize(NULL, self_len); + result = (PyByteArrayObject *) PyByteArray_FromStringAndSize(NULL, self_len); if (result == NULL) return NULL; - result_s = PyBytes_AS_STRING(result); + result_s = PyByteArray_AS_STRING(result); Py_MEMCPY(result_s, self_s, self_len); /* change everything in-place, starting with this one */ @@ -1827,8 +1827,8 @@ replace_substring_in_place(PyBytesObject *self, } /* len(self)>=1, len(from)==1, len(to)>=2, maxcount>=1 */ -Py_LOCAL(PyBytesObject *) -replace_single_character(PyBytesObject *self, +Py_LOCAL(PyByteArrayObject *) +replace_single_character(PyByteArrayObject *self, char from_c, const char *to_s, Py_ssize_t to_len, Py_ssize_t maxcount) @@ -1837,10 +1837,10 @@ replace_single_character(PyBytesObject *self, char *start, *next, *end; Py_ssize_t self_len, result_len; Py_ssize_t count, product; - PyBytesObject *result; + PyByteArrayObject *result; - self_s = PyBytes_AS_STRING(self); - self_len = PyBytes_GET_SIZE(self); + self_s = PyByteArray_AS_STRING(self); + self_len = PyByteArray_GET_SIZE(self); count = countchar(self_s, self_len, from_c, maxcount); if (count == 0) { @@ -1861,10 +1861,10 @@ replace_single_character(PyBytesObject *self, return NULL; } - if ( (result = (PyBytesObject *) - PyBytes_FromStringAndSize(NULL, result_len)) == NULL) + if ( (result = (PyByteArrayObject *) + PyByteArray_FromStringAndSize(NULL, result_len)) == NULL) return NULL; - result_s = PyBytes_AS_STRING(result); + result_s = PyByteArray_AS_STRING(result); start = self_s; end = self_s + self_len; @@ -1894,8 +1894,8 @@ replace_single_character(PyBytesObject *self, } /* len(self)>=1, len(from)>=2, len(to)>=2, maxcount>=1 */ -Py_LOCAL(PyBytesObject *) -replace_substring(PyBytesObject *self, +Py_LOCAL(PyByteArrayObject *) +replace_substring(PyByteArrayObject *self, const char *from_s, Py_ssize_t from_len, const char *to_s, Py_ssize_t to_len, Py_ssize_t maxcount) @@ -1904,10 +1904,10 @@ replace_substring(PyBytesObject *self, char *start, *next, *end; Py_ssize_t self_len, result_len; Py_ssize_t count, offset, product; - PyBytesObject *result; + PyByteArrayObject *result; - self_s = PyBytes_AS_STRING(self); - self_len = PyBytes_GET_SIZE(self); + self_s = PyByteArray_AS_STRING(self); + self_len = PyByteArray_GET_SIZE(self); count = countstring(self_s, self_len, from_s, from_len, @@ -1930,10 +1930,10 @@ replace_substring(PyBytesObject *self, return NULL; } - if ( (result = (PyBytesObject *) - PyBytes_FromStringAndSize(NULL, result_len)) == NULL) + if ( (result = (PyByteArrayObject *) + PyByteArray_FromStringAndSize(NULL, result_len)) == NULL) return NULL; - result_s = PyBytes_AS_STRING(result); + result_s = PyByteArray_AS_STRING(result); start = self_s; end = self_s + self_len; @@ -1965,15 +1965,15 @@ replace_substring(PyBytesObject *self, } -Py_LOCAL(PyBytesObject *) -replace(PyBytesObject *self, +Py_LOCAL(PyByteArrayObject *) +replace(PyByteArrayObject *self, const char *from_s, Py_ssize_t from_len, const char *to_s, Py_ssize_t to_len, Py_ssize_t maxcount) { if (maxcount < 0) { maxcount = PY_SSIZE_T_MAX; - } else if (maxcount == 0 || PyBytes_GET_SIZE(self) == 0) { + } else if (maxcount == 0 || PyByteArray_GET_SIZE(self) == 0) { /* nothing to do; return the original bytes */ return return_self(self); } @@ -1996,7 +1996,7 @@ replace(PyBytesObject *self, /* Except for "".replace("", "A") == "A" there is no way beyond this */ /* point for an empty self bytes to generate a non-empty bytes */ /* Special case so the remaining code always gets a non-empty bytes */ - if (PyBytes_GET_SIZE(self) == 0) { + if (PyByteArray_GET_SIZE(self) == 0) { return return_self(self); } @@ -2044,7 +2044,7 @@ old replaced by new. If the optional argument count is\n\ given, only the first count occurrences are replaced."); static PyObject * -bytes_replace(PyBytesObject *self, PyObject *args) +bytes_replace(PyByteArrayObject *self, PyObject *args) { Py_ssize_t count = -1; PyObject *from, *to, *res; @@ -2060,7 +2060,7 @@ bytes_replace(PyBytesObject *self, PyObject *args) return NULL; } - res = (PyObject *)replace((PyBytesObject *) self, + res = (PyObject *)replace((PyByteArrayObject *) self, vfrom.buf, vfrom.len, vto.buf, vto.len, count); @@ -2084,7 +2084,7 @@ bytes_replace(PyBytesObject *self, PyObject *args) (maxsplit >= MAX_PREALLOC ? MAX_PREALLOC : maxsplit+1) #define SPLIT_APPEND(data, left, right) \ - str = PyBytes_FromStringAndSize((data) + (left), \ + str = PyByteArray_FromStringAndSize((data) + (left), \ (right) - (left)); \ if (str == NULL) \ goto onError; \ @@ -2096,7 +2096,7 @@ bytes_replace(PyBytesObject *self, PyObject *args) Py_DECREF(str); #define SPLIT_ADD(data, left, right) { \ - str = PyBytes_FromStringAndSize((data) + (left), \ + str = PyByteArray_FromStringAndSize((data) + (left), \ (right) - (left)); \ if (str == NULL) \ goto onError; \ @@ -2195,11 +2195,11 @@ 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(PyBytesObject *self, PyObject *args) +bytes_split(PyByteArrayObject *self, PyObject *args) { - Py_ssize_t len = PyBytes_GET_SIZE(self), n, i, j; + Py_ssize_t len = PyByteArray_GET_SIZE(self), n, i, j; Py_ssize_t maxsplit = -1, count = 0; - const char *s = PyBytes_AS_STRING(self), *sub; + const char *s = PyByteArray_AS_STRING(self), *sub; PyObject *list, *str, *subobj = Py_None; Py_buffer vsub; #ifdef USE_FAST @@ -2277,7 +2277,7 @@ make_nullbytes_unique(PyObject *result) assert(PyTuple_GET_SIZE(result) == 3); for (i = 0; i < 3; i++) { if (PyTuple_GET_ITEM(result, i) == (PyObject *)nullbytes) { - PyObject *new = PyBytes_FromStringAndSize(NULL, 0); + PyObject *new = PyByteArray_FromStringAndSize(NULL, 0); if (new == NULL) { Py_DECREF(result); result = NULL; @@ -2299,19 +2299,19 @@ 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(PyBytesObject *self, PyObject *sep_obj) +bytes_partition(PyByteArrayObject *self, PyObject *sep_obj) { PyObject *bytesep, *result; - bytesep = PyBytes_FromObject(sep_obj); + bytesep = PyByteArray_FromObject(sep_obj); if (! bytesep) return NULL; result = stringlib_partition( (PyObject*) self, - PyBytes_AS_STRING(self), PyBytes_GET_SIZE(self), + PyByteArray_AS_STRING(self), PyByteArray_GET_SIZE(self), bytesep, - PyBytes_AS_STRING(bytesep), PyBytes_GET_SIZE(bytesep) + PyByteArray_AS_STRING(bytesep), PyByteArray_GET_SIZE(bytesep) ); Py_DECREF(bytesep); @@ -2327,19 +2327,19 @@ part after it. If the separator is not found, returns two empty\n\ bytearray objects and B."); static PyObject * -bytes_rpartition(PyBytesObject *self, PyObject *sep_obj) +bytes_rpartition(PyByteArrayObject *self, PyObject *sep_obj) { PyObject *bytesep, *result; - bytesep = PyBytes_FromObject(sep_obj); + bytesep = PyByteArray_FromObject(sep_obj); if (! bytesep) return NULL; result = stringlib_rpartition( (PyObject*) self, - PyBytes_AS_STRING(self), PyBytes_GET_SIZE(self), + PyByteArray_AS_STRING(self), PyByteArray_GET_SIZE(self), bytesep, - PyBytes_AS_STRING(bytesep), PyBytes_GET_SIZE(bytesep) + PyByteArray_AS_STRING(bytesep), PyByteArray_GET_SIZE(bytesep) ); Py_DECREF(bytesep); @@ -2430,11 +2430,11 @@ 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(PyBytesObject *self, PyObject *args) +bytes_rsplit(PyByteArrayObject *self, PyObject *args) { - Py_ssize_t len = PyBytes_GET_SIZE(self), n, i, j; + Py_ssize_t len = PyByteArray_GET_SIZE(self), n, i, j; Py_ssize_t maxsplit = -1, count = 0; - const char *s = PyBytes_AS_STRING(self), *sub; + const char *s = PyByteArray_AS_STRING(self), *sub; PyObject *list, *str, *subobj = Py_None; Py_buffer vsub; @@ -2496,7 +2496,7 @@ PyDoc_STRVAR(reverse__doc__, \n\ Reverse the order of the values in B in place."); static PyObject * -bytes_reverse(PyBytesObject *self, PyObject *unused) +bytes_reverse(PyByteArrayObject *self, PyObject *unused) { char swap, *head, *tail; Py_ssize_t i, j, n = Py_SIZE(self); @@ -2518,7 +2518,7 @@ PyDoc_STRVAR(insert__doc__, \n\ Insert a single item into the bytearray before the given index."); static PyObject * -bytes_insert(PyBytesObject *self, PyObject *args) +bytes_insert(PyByteArrayObject *self, PyObject *args) { int value; Py_ssize_t where, n = Py_SIZE(self); @@ -2536,7 +2536,7 @@ bytes_insert(PyBytesObject *self, PyObject *args) "byte must be in range(0, 256)"); return NULL; } - if (PyBytes_Resize((PyObject *)self, n + 1) < 0) + if (PyByteArray_Resize((PyObject *)self, n + 1) < 0) return NULL; if (where < 0) { @@ -2557,7 +2557,7 @@ PyDoc_STRVAR(append__doc__, \n\ Append a single item to the end of B."); static PyObject * -bytes_append(PyBytesObject *self, PyObject *arg) +bytes_append(PyByteArrayObject *self, PyObject *arg) { int value; Py_ssize_t n = Py_SIZE(self); @@ -2569,7 +2569,7 @@ bytes_append(PyBytesObject *self, PyObject *arg) "cannot add more objects to bytes"); return NULL; } - if (PyBytes_Resize((PyObject *)self, n + 1) < 0) + if (PyByteArray_Resize((PyObject *)self, n + 1) < 0) return NULL; self->ob_bytes[n] = value; @@ -2583,7 +2583,7 @@ PyDoc_STRVAR(extend__doc__, Append all the elements from the iterator or sequence to the\n\ end of B."); static PyObject * -bytes_extend(PyBytesObject *self, PyObject *arg) +bytes_extend(PyByteArrayObject *self, PyObject *arg) { PyObject *it, *item, *bytes_obj; Py_ssize_t buf_size = 0, len = 0; @@ -2605,10 +2605,10 @@ bytes_extend(PyBytesObject *self, PyObject *arg) /* Try to determine the length of the argument. 32 is abitrary. */ buf_size = _PyObject_LengthHint(arg, 32); - bytes_obj = PyBytes_FromStringAndSize(NULL, buf_size); + bytes_obj = PyByteArray_FromStringAndSize(NULL, buf_size); if (bytes_obj == NULL) return NULL; - buf = PyBytes_AS_STRING(bytes_obj); + buf = PyByteArray_AS_STRING(bytes_obj); while ((item = PyIter_Next(it)) != NULL) { if (! _getbytevalue(item, &value)) { @@ -2622,20 +2622,20 @@ bytes_extend(PyBytesObject *self, PyObject *arg) if (len >= buf_size) { buf_size = len + (len >> 1) + 1; - if (PyBytes_Resize((PyObject *)bytes_obj, buf_size) < 0) { + if (PyByteArray_Resize((PyObject *)bytes_obj, buf_size) < 0) { Py_DECREF(it); Py_DECREF(bytes_obj); return NULL; } /* Recompute the `buf' pointer, since the resizing operation may have invalidated it. */ - buf = PyBytes_AS_STRING(bytes_obj); + buf = PyByteArray_AS_STRING(bytes_obj); } } Py_DECREF(it); /* Resize down to exact size. */ - if (PyBytes_Resize((PyObject *)bytes_obj, len) < 0) { + if (PyByteArray_Resize((PyObject *)bytes_obj, len) < 0) { Py_DECREF(bytes_obj); return NULL; } @@ -2653,7 +2653,7 @@ PyDoc_STRVAR(pop__doc__, Remove and return a single item from B. If no index\n\ argument is give, will pop the last value."); static PyObject * -bytes_pop(PyBytesObject *self, PyObject *args) +bytes_pop(PyByteArrayObject *self, PyObject *args) { int value; Py_ssize_t where = -1, n = Py_SIZE(self); @@ -2675,7 +2675,7 @@ bytes_pop(PyBytesObject *self, PyObject *args) value = self->ob_bytes[where]; memmove(self->ob_bytes + where, self->ob_bytes + where + 1, n - where); - if (PyBytes_Resize((PyObject *)self, n - 1) < 0) + if (PyByteArray_Resize((PyObject *)self, n - 1) < 0) return NULL; return PyLong_FromLong(value); @@ -2686,7 +2686,7 @@ PyDoc_STRVAR(remove__doc__, \n\ Remove the first occurance of a value in B."); static PyObject * -bytes_remove(PyBytesObject *self, PyObject *arg) +bytes_remove(PyByteArrayObject *self, PyObject *arg) { int value; Py_ssize_t where, n = Py_SIZE(self); @@ -2704,7 +2704,7 @@ bytes_remove(PyBytesObject *self, PyObject *arg) } memmove(self->ob_bytes + where, self->ob_bytes + where + 1, n - where); - if (PyBytes_Resize((PyObject *)self, n - 1) < 0) + if (PyByteArray_Resize((PyObject *)self, n - 1) < 0) return NULL; Py_RETURN_NONE; @@ -2738,7 +2738,7 @@ PyDoc_STRVAR(strip__doc__, Strip leading and trailing bytes contained in the argument.\n\ If the argument is omitted, strip ASCII whitespace."); static PyObject * -bytes_strip(PyBytesObject *self, PyObject *args) +bytes_strip(PyByteArrayObject *self, PyObject *args) { Py_ssize_t left, right, mysize, argsize; void *myptr, *argptr; @@ -2765,7 +2765,7 @@ bytes_strip(PyBytesObject *self, PyObject *args) right = rstrip_helper(myptr, mysize, argptr, argsize); if (arg != Py_None) PyObject_ReleaseBuffer(arg, &varg); - return PyBytes_FromStringAndSize(self->ob_bytes + left, right - left); + return PyByteArray_FromStringAndSize(self->ob_bytes + left, right - left); } PyDoc_STRVAR(lstrip__doc__, @@ -2774,7 +2774,7 @@ PyDoc_STRVAR(lstrip__doc__, Strip leading bytes contained in the argument.\n\ If the argument is omitted, strip leading ASCII whitespace."); static PyObject * -bytes_lstrip(PyBytesObject *self, PyObject *args) +bytes_lstrip(PyByteArrayObject *self, PyObject *args) { Py_ssize_t left, right, mysize, argsize; void *myptr, *argptr; @@ -2798,7 +2798,7 @@ bytes_lstrip(PyBytesObject *self, PyObject *args) right = mysize; if (arg != Py_None) PyObject_ReleaseBuffer(arg, &varg); - return PyBytes_FromStringAndSize(self->ob_bytes + left, right - left); + return PyByteArray_FromStringAndSize(self->ob_bytes + left, right - left); } PyDoc_STRVAR(rstrip__doc__, @@ -2807,7 +2807,7 @@ PyDoc_STRVAR(rstrip__doc__, Strip trailing bytes contained in the argument.\n\ If the argument is omitted, strip trailing ASCII whitespace."); static PyObject * -bytes_rstrip(PyBytesObject *self, PyObject *args) +bytes_rstrip(PyByteArrayObject *self, PyObject *args) { Py_ssize_t left, right, mysize, argsize; void *myptr, *argptr; @@ -2831,7 +2831,7 @@ bytes_rstrip(PyBytesObject *self, PyObject *args) right = rstrip_helper(myptr, mysize, argptr, argsize); if (arg != Py_None) PyObject_ReleaseBuffer(arg, &varg); - return PyBytes_FromStringAndSize(self->ob_bytes + left, right - left); + return PyByteArray_FromStringAndSize(self->ob_bytes + left, right - left); } PyDoc_STRVAR(decode_doc, @@ -2863,7 +2863,7 @@ PyDoc_STRVAR(alloc_doc, Returns the number of bytes actually allocated."); static PyObject * -bytes_alloc(PyBytesObject *self) +bytes_alloc(PyByteArrayObject *self) { return PyLong_FromSsize_t(self->ob_alloc); } @@ -2874,7 +2874,7 @@ PyDoc_STRVAR(join_doc, Concatenates any number of bytearray objects, with B in between each pair."); static PyObject * -bytes_join(PyBytesObject *self, PyObject *it) +bytes_join(PyByteArrayObject *self, PyObject *it) { PyObject *seq; Py_ssize_t mysize = Py_SIZE(self); @@ -2895,7 +2895,7 @@ bytes_join(PyBytesObject *self, PyObject *it) /* XXX Shouldn't we use _getbuffer() on these items instead? */ for (i = 0; i < n; i++) { PyObject *obj = items[i]; - if (!PyBytes_Check(obj) && !PyString_Check(obj)) { + if (!PyByteArray_Check(obj) && !PyString_Check(obj)) { PyErr_Format(PyExc_TypeError, "can only join an iterable of bytes " "(item %ld has type '%.100s')", @@ -2913,16 +2913,16 @@ bytes_join(PyBytesObject *self, PyObject *it) } /* Allocate the result, and copy the bytes */ - result = PyBytes_FromStringAndSize(NULL, totalsize); + result = PyByteArray_FromStringAndSize(NULL, totalsize); if (result == NULL) goto error; - dest = PyBytes_AS_STRING(result); + dest = PyByteArray_AS_STRING(result); for (i = 0; i < n; i++) { PyObject *obj = items[i]; Py_ssize_t size = Py_SIZE(obj); char *buf; - if (PyBytes_Check(obj)) - buf = PyBytes_AS_STRING(obj); + if (PyByteArray_Check(obj)) + buf = PyByteArray_AS_STRING(obj); else buf = PyString_AS_STRING(obj); if (i) { @@ -2981,10 +2981,10 @@ bytes_fromhex(PyObject *cls, PyObject *args) hexlen = PyUnicode_GET_SIZE(hexobj); hex = PyUnicode_AS_UNICODE(hexobj); byteslen = hexlen/2; /* This overestimates if there are spaces */ - newbytes = PyBytes_FromStringAndSize(NULL, byteslen); + newbytes = PyByteArray_FromStringAndSize(NULL, byteslen); if (!newbytes) return NULL; - buf = PyBytes_AS_STRING(newbytes); + buf = PyByteArray_AS_STRING(newbytes); for (i = j = 0; i < hexlen; i += 2) { /* skip over spaces in the input */ while (hex[i] == ' ') @@ -3001,7 +3001,7 @@ bytes_fromhex(PyObject *cls, PyObject *args) } buf[j++] = (top << 4) + bot; } - if (PyBytes_Resize(newbytes, j) < 0) + if (PyByteArray_Resize(newbytes, j) < 0) goto error; return newbytes; @@ -3013,7 +3013,7 @@ bytes_fromhex(PyObject *cls, PyObject *args) PyDoc_STRVAR(reduce_doc, "Return state information for pickling."); static PyObject * -bytes_reduce(PyBytesObject *self) +bytes_reduce(PyByteArrayObject *self) { PyObject *latin1, *dict; if (self->ob_bytes) @@ -3034,7 +3034,7 @@ bytes_reduce(PyBytesObject *self) static PySequenceMethods bytes_as_sequence = { (lenfunc)bytes_length, /* sq_length */ - (binaryfunc)PyBytes_Concat, /* sq_concat */ + (binaryfunc)PyByteArray_Concat, /* sq_concat */ (ssizeargfunc)bytes_repeat, /* sq_repeat */ (ssizeargfunc)bytes_getitem, /* sq_item */ 0, /* sq_slice */ @@ -3139,10 +3139,10 @@ Construct a zero-initialized bytearray of the given length."); static PyObject *bytes_iter(PyObject *seq); -PyTypeObject PyBytes_Type = { +PyTypeObject PyByteArray_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "bytearray", - sizeof(PyBytesObject), + sizeof(PyByteArrayObject), 0, (destructor)bytes_dealloc, /* tp_dealloc */ 0, /* tp_print */ @@ -3186,7 +3186,7 @@ PyTypeObject PyBytes_Type = { typedef struct { PyObject_HEAD Py_ssize_t it_index; - PyBytesObject *it_seq; /* Set to NULL when iterator is exhausted */ + PyByteArrayObject *it_seq; /* Set to NULL when iterator is exhausted */ } bytesiterobject; static void @@ -3207,16 +3207,16 @@ bytesiter_traverse(bytesiterobject *it, visitproc visit, void *arg) static PyObject * bytesiter_next(bytesiterobject *it) { - PyBytesObject *seq; + PyByteArrayObject *seq; PyObject *item; assert(it != NULL); seq = it->it_seq; if (seq == NULL) return NULL; - assert(PyBytes_Check(seq)); + assert(PyByteArray_Check(seq)); - if (it->it_index < PyBytes_GET_SIZE(seq)) { + if (it->it_index < PyByteArray_GET_SIZE(seq)) { item = PyLong_FromLong( (unsigned char)seq->ob_bytes[it->it_index]); if (item != NULL) @@ -3234,7 +3234,7 @@ bytesiter_length_hint(bytesiterobject *it) { Py_ssize_t len = 0; if (it->it_seq) - len = PyBytes_GET_SIZE(it->it_seq) - it->it_index; + len = PyByteArray_GET_SIZE(it->it_seq) - it->it_index; return PyLong_FromSsize_t(len); } @@ -3247,7 +3247,7 @@ static PyMethodDef bytesiter_methods[] = { {NULL, NULL} /* sentinel */ }; -PyTypeObject PyBytesIter_Type = { +PyTypeObject PyByteArrayIter_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "bytearray_iterator", /* tp_name */ sizeof(bytesiterobject), /* tp_basicsize */ @@ -3285,16 +3285,16 @@ bytes_iter(PyObject *seq) { bytesiterobject *it; - if (!PyBytes_Check(seq)) { + if (!PyByteArray_Check(seq)) { PyErr_BadInternalCall(); return NULL; } - it = PyObject_GC_New(bytesiterobject, &PyBytesIter_Type); + it = PyObject_GC_New(bytesiterobject, &PyByteArrayIter_Type); if (it == NULL) return NULL; it->it_index = 0; Py_INCREF(seq); - it->it_seq = (PyBytesObject *)seq; + it->it_seq = (PyByteArrayObject *)seq; _PyObject_GC_TRACK(it); return (PyObject *)it; } diff --git a/Objects/longobject.c b/Objects/longobject.c index fa0142f..d2557df 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -3518,13 +3518,13 @@ long_new(PyTypeObject *type, PyObject *args, PyObject *kwds) return PyLong_FromUnicode(PyUnicode_AS_UNICODE(x), PyUnicode_GET_SIZE(x), base); - else if (PyBytes_Check(x) || PyString_Check(x)) { + else if (PyByteArray_Check(x) || PyString_Check(x)) { /* Since PyLong_FromString doesn't have a length parameter, * check here for possible NULs in the string. */ char *string; int size = Py_SIZE(x); - if (PyBytes_Check(x)) - string = PyBytes_AS_STRING(x); + if (PyByteArray_Check(x)) + string = PyByteArray_AS_STRING(x); else string = PyString_AS_STRING(x); if (strlen(string) != size) { diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c index c60c53c..27ceb7a 100644 --- a/Objects/memoryobject.c +++ b/Objects/memoryobject.c @@ -254,12 +254,12 @@ PyMemoryView_GetContiguous(PyObject *obj, int buffertype, char fort) "for a non-contiguousobject."); return NULL; } - bytes = PyBytes_FromStringAndSize(NULL, view->len); + bytes = PyByteArray_FromStringAndSize(NULL, view->len); if (bytes == NULL) { PyObject_ReleaseBuffer(obj, view); return NULL; } - dest = PyBytes_AS_STRING(bytes); + dest = PyByteArray_AS_STRING(bytes); /* different copying strategy depending on whether or not any pointer de-referencing is needed */ @@ -382,7 +382,7 @@ static PyGetSetDef memory_getsetlist[] ={ static PyObject * memory_tobytes(PyMemoryViewObject *mem, PyObject *noargs) { - return PyBytes_FromObject((PyObject *)mem); + return PyByteArray_FromObject((PyObject *)mem); } static PyObject * @@ -451,8 +451,8 @@ memory_str(PyMemoryViewObject *self) if (PyObject_GetBuffer((PyObject *)self, &view, PyBUF_FULL) < 0) return NULL; - res = PyBytes_FromStringAndSize(NULL, view.len); - PyBuffer_ToContiguous(PyBytes_AS_STRING(res), &view, view.len, 'C'); + res = PyByteArray_FromStringAndSize(NULL, view.len); + PyBuffer_ToContiguous(PyByteArray_AS_STRING(res), &view, view.len, 'C'); PyObject_ReleaseBuffer((PyObject *)self, &view); return res; } @@ -522,7 +522,7 @@ memory_subscript(PyMemoryViewObject *self, PyObject *key) { ptr = *((char **)ptr) + view->suboffsets[0]; } - return PyBytes_FromStringAndSize(ptr, view->itemsize); + return PyByteArray_FromStringAndSize(ptr, view->itemsize); } else { /* Return a new memory-view object */ diff --git a/Objects/object.c b/Objects/object.c index 0d317b2..5dc3436 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -1495,7 +1495,7 @@ _Py_ReadyTypes(void) if (PyType_Ready(&PyBool_Type) < 0) Py_FatalError("Can't initialize 'bool'"); - if (PyType_Ready(&PyBytes_Type) < 0) + if (PyType_Ready(&PyByteArray_Type) < 0) Py_FatalError("Can't initialize 'bytes'"); if (PyType_Ready(&PyString_Type) < 0) diff --git a/Objects/stringobject.c b/Objects/stringobject.c index 0cc48c3..70f3a6c 100644 --- a/Objects/stringobject.c +++ b/Objects/stringobject.c @@ -1469,7 +1469,7 @@ string_join(PyObject *self, PyObject *orig) for (i = 0; i < seqlen; i++) { const size_t old_sz = sz; item = PySequence_Fast_GET_ITEM(seq, i); - if (!PyString_Check(item) && !PyBytes_Check(item)) { + if (!PyString_Check(item) && !PyByteArray_Check(item)) { PyErr_Format(PyExc_TypeError, "sequence item %zd: expected bytes," " %.80s found", @@ -1496,7 +1496,7 @@ string_join(PyObject *self, PyObject *orig) } /* Catenate everything. */ - /* I'm not worried about a PyBytes item growing because there's + /* I'm not worried about a PyByteArray item growing because there's nowhere in this function where we release the GIL. */ p = PyString_AS_STRING(res); for (i = 0; i < seqlen; ++i) { @@ -1511,7 +1511,7 @@ string_join(PyObject *self, PyObject *orig) if (PyString_Check(item)) q = PyString_AS_STRING(item); else - q = PyBytes_AS_STRING(item); + q = PyByteArray_AS_STRING(item); Py_MEMCPY(p, q, n); p += n; } diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 8201c7e..445d56a 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -1764,11 +1764,11 @@ PyObject *PyUnicode_EncodeUTF7(const Py_UNICODE *s, if (size == 0) return PyString_FromStringAndSize(NULL, 0); - v = PyBytes_FromStringAndSize(NULL, cbAllocated); + v = PyByteArray_FromStringAndSize(NULL, cbAllocated); if (v == NULL) return NULL; - start = out = PyBytes_AS_STRING(v); + start = out = PyByteArray_AS_STRING(v); for (;i < size; ++i) { Py_UNICODE ch = s[i]; @@ -1834,7 +1834,7 @@ PyObject *PyUnicode_EncodeUTF7(const Py_UNICODE *s, *out++ = '-'; } - result = PyString_FromStringAndSize(PyBytes_AS_STRING(v), out - start); + result = PyString_FromStringAndSize(PyByteArray_AS_STRING(v), out - start); Py_DECREF(v); return result; } @@ -2385,12 +2385,12 @@ PyUnicode_EncodeUTF32(const Py_UNICODE *s, 0xDC00 <= s[i+1] && s[i+1] <= 0xDFFF) pairs++; #endif - v = PyBytes_FromStringAndSize(NULL, + v = PyByteArray_FromStringAndSize(NULL, 4 * (size - pairs + (byteorder == 0))); if (v == NULL) return NULL; - p = (unsigned char *)PyBytes_AS_STRING(v); + p = (unsigned char *)PyByteArray_AS_STRING(v); if (byteorder == 0) STORECHAR(0xFEFF); if (size == 0) @@ -2427,7 +2427,7 @@ PyUnicode_EncodeUTF32(const Py_UNICODE *s, } done: - result = PyString_FromStringAndSize(PyBytes_AS_STRING(v), Py_SIZE(v)); + result = PyString_FromStringAndSize(PyByteArray_AS_STRING(v), Py_SIZE(v)); Py_DECREF(v); return result; #undef STORECHAR @@ -2654,12 +2654,12 @@ PyUnicode_EncodeUTF16(const Py_UNICODE *s, if (s[i] >= 0x10000) pairs++; #endif - v = PyBytes_FromStringAndSize(NULL, + v = PyByteArray_FromStringAndSize(NULL, 2 * (size + pairs + (byteorder == 0))); if (v == NULL) return NULL; - p = (unsigned char *)PyBytes_AS_STRING(v); + p = (unsigned char *)PyByteArray_AS_STRING(v); if (byteorder == 0) STORECHAR(0xFEFF); if (size == 0) @@ -2691,7 +2691,7 @@ PyUnicode_EncodeUTF16(const Py_UNICODE *s, } done: - result = PyString_FromStringAndSize(PyBytes_AS_STRING(v), Py_SIZE(v)); + result = PyString_FromStringAndSize(PyByteArray_AS_STRING(v), Py_SIZE(v)); Py_DECREF(v); return result; #undef STORECHAR @@ -3004,7 +3004,7 @@ PyObject *PyUnicode_EncodeUnicodeEscape(const Py_UNICODE *s, escape. */ - repr = PyBytes_FromStringAndSize(NULL, + repr = PyByteArray_FromStringAndSize(NULL, #ifdef Py_UNICODE_WIDE + 10*size #else @@ -3014,7 +3014,7 @@ PyObject *PyUnicode_EncodeUnicodeEscape(const Py_UNICODE *s, if (repr == NULL) return NULL; - p = PyBytes_AS_STRING(repr); + p = PyByteArray_AS_STRING(repr); while (size-- > 0) { Py_UNICODE ch = *s++; @@ -3106,8 +3106,8 @@ PyObject *PyUnicode_EncodeUnicodeEscape(const Py_UNICODE *s, *p++ = (char) ch; } - result = PyString_FromStringAndSize(PyBytes_AS_STRING(repr), - p - PyBytes_AS_STRING(repr)); + result = PyString_FromStringAndSize(PyByteArray_AS_STRING(repr), + p - PyByteArray_AS_STRING(repr)); Py_DECREF(repr); return result; } @@ -3124,8 +3124,8 @@ PyObject *PyUnicode_AsUnicodeEscapeString(PyObject *unicode) if (!s) return NULL; - result = PyString_FromStringAndSize(PyBytes_AS_STRING(s), - PyBytes_GET_SIZE(s)); + result = PyString_FromStringAndSize(PyByteArray_AS_STRING(s), + PyByteArray_GET_SIZE(s)); Py_DECREF(s); return result; } @@ -3257,16 +3257,16 @@ PyObject *PyUnicode_EncodeRawUnicodeEscape(const Py_UNICODE *s, char *q; #ifdef Py_UNICODE_WIDE - repr = PyBytes_FromStringAndSize(NULL, 10 * size); + repr = PyByteArray_FromStringAndSize(NULL, 10 * size); #else - repr = PyBytes_FromStringAndSize(NULL, 6 * size); + repr = PyByteArray_FromStringAndSize(NULL, 6 * size); #endif if (repr == NULL) return NULL; if (size == 0) goto done; - p = q = PyBytes_AS_STRING(repr); + p = q = PyByteArray_AS_STRING(repr); while (size-- > 0) { Py_UNICODE ch = *s++; #ifdef Py_UNICODE_WIDE @@ -3327,7 +3327,7 @@ PyObject *PyUnicode_EncodeRawUnicodeEscape(const Py_UNICODE *s, size = p - q; done: - result = PyString_FromStringAndSize(PyBytes_AS_STRING(repr), size); + result = PyString_FromStringAndSize(PyByteArray_AS_STRING(repr), size); Py_DECREF(repr); return result; } @@ -3344,8 +3344,8 @@ PyObject *PyUnicode_AsRawUnicodeEscapeString(PyObject *unicode) if (!s) return NULL; - result = PyString_FromStringAndSize(PyBytes_AS_STRING(s), - PyBytes_GET_SIZE(s)); + result = PyString_FromStringAndSize(PyByteArray_AS_STRING(s), + PyByteArray_GET_SIZE(s)); Py_DECREF(s); return result; } @@ -3578,10 +3578,10 @@ static PyObject *unicode_encode_ucs1(const Py_UNICODE *p, replacements, if we need more, we'll resize */ if (size == 0) return PyString_FromStringAndSize(NULL, 0); - res = PyBytes_FromStringAndSize(NULL, size); + res = PyByteArray_FromStringAndSize(NULL, size); if (res == NULL) return NULL; - str = PyBytes_AS_STRING(res); + str = PyByteArray_AS_STRING(res); ressize = size; while (p<endp) { @@ -3631,7 +3631,7 @@ static PyObject *unicode_encode_ucs1(const Py_UNICODE *p, p = collend; break; case 4: /* xmlcharrefreplace */ - respos = str - PyBytes_AS_STRING(res); + respos = str - PyByteArray_AS_STRING(res); /* determine replacement size (temporarily (mis)uses p) */ for (p = collstart, repsize = 0; p < collend; ++p) { if (*p<10) @@ -3658,9 +3658,9 @@ static PyObject *unicode_encode_ucs1(const Py_UNICODE *p, if (requiredsize > ressize) { if (requiredsize<2*ressize) requiredsize = 2*ressize; - if (PyBytes_Resize(res, requiredsize)) + if (PyByteArray_Resize(res, requiredsize)) goto onError; - str = PyBytes_AS_STRING(res) + respos; + str = PyByteArray_AS_STRING(res) + respos; ressize = requiredsize; } /* generate replacement (temporarily (mis)uses p) */ @@ -3678,17 +3678,17 @@ static PyObject *unicode_encode_ucs1(const Py_UNICODE *p, /* need more space? (at least enough for what we have+the replacement+the rest of the string, so we won't have to check space for encodable characters) */ - respos = str - PyBytes_AS_STRING(res); + respos = str - PyByteArray_AS_STRING(res); repsize = PyUnicode_GET_SIZE(repunicode); requiredsize = respos+repsize+(endp-collend); if (requiredsize > ressize) { if (requiredsize<2*ressize) requiredsize = 2*ressize; - if (PyBytes_Resize(res, requiredsize)) { + if (PyByteArray_Resize(res, requiredsize)) { Py_DECREF(repunicode); goto onError; } - str = PyBytes_AS_STRING(res) + respos; + str = PyByteArray_AS_STRING(res) + respos; ressize = requiredsize; } /* check if there is anything unencodable in the replacement @@ -3708,8 +3708,8 @@ static PyObject *unicode_encode_ucs1(const Py_UNICODE *p, } } } - result = PyString_FromStringAndSize(PyBytes_AS_STRING(res), - str - PyBytes_AS_STRING(res)); + result = PyString_FromStringAndSize(PyByteArray_AS_STRING(res), + str - PyByteArray_AS_STRING(res)); onError: Py_DECREF(res); Py_XDECREF(errorHandler); |