Renamed PyBytes to PyByteArray

This commit is contained in:
Christian Heimes 2008-05-26 13:22:05 +00:00
parent 96d02f3c1e
commit 9c4756ea26
31 changed files with 397 additions and 397 deletions

View File

@ -2,7 +2,7 @@
#define Py_BYTES_CTYPE_H
/*
* The internal implementation behind PyString (bytes) and PyBytes (buffer)
* The internal implementation behind PyBytes (bytes) and PyByteArray (bytearray)
* methods of the given names, they operate on ASCII byte strings.
*/
extern PyObject* _Py_bytes_isspace(const char *cptr, Py_ssize_t len);

View File

@ -8,7 +8,7 @@ extern "C" {
#include <stdarg.h>
/* Type PyBytesObject represents a mutable array of bytes.
/* Type PyByteArrayObject represents a mutable array of bytes.
* The Python API is that of a sequence;
* the bytes are mapped to ints in [0, 256).
* Bytes are not characters; they may be used to encode characters.
@ -25,27 +25,27 @@ typedef struct {
int ob_exports; /* how many buffer exports */
Py_ssize_t ob_alloc; /* How many bytes allocated */
char *ob_bytes;
} PyBytesObject;
} PyByteArrayObject;
/* Type object */
PyAPI_DATA(PyTypeObject) PyBytes_Type;
PyAPI_DATA(PyTypeObject) PyBytesIter_Type;
PyAPI_DATA(PyTypeObject) PyByteArray_Type;
PyAPI_DATA(PyTypeObject) PyByteArrayIter_Type;
/* Type check macros */
#define PyBytes_Check(self) PyObject_TypeCheck(self, &PyBytes_Type)
#define PyBytes_CheckExact(self) (Py_TYPE(self) == &PyBytes_Type)
#define PyByteArray_Check(self) PyObject_TypeCheck(self, &PyByteArray_Type)
#define PyByteArray_CheckExact(self) (Py_TYPE(self) == &PyByteArray_Type)
/* Direct API functions */
PyAPI_FUNC(PyObject *) PyBytes_FromObject(PyObject *);
PyAPI_FUNC(PyObject *) PyBytes_Concat(PyObject *, PyObject *);
PyAPI_FUNC(PyObject *) PyBytes_FromStringAndSize(const char *, Py_ssize_t);
PyAPI_FUNC(Py_ssize_t) PyBytes_Size(PyObject *);
PyAPI_FUNC(char *) PyBytes_AsString(PyObject *);
PyAPI_FUNC(int) PyBytes_Resize(PyObject *, Py_ssize_t);
PyAPI_FUNC(PyObject *) PyByteArray_FromObject(PyObject *);
PyAPI_FUNC(PyObject *) PyByteArray_Concat(PyObject *, PyObject *);
PyAPI_FUNC(PyObject *) PyByteArray_FromStringAndSize(const char *, Py_ssize_t);
PyAPI_FUNC(Py_ssize_t) PyByteArray_Size(PyObject *);
PyAPI_FUNC(char *) PyByteArray_AsString(PyObject *);
PyAPI_FUNC(int) PyByteArray_Resize(PyObject *, Py_ssize_t);
/* Macros, trading safety for speed */
#define PyBytes_AS_STRING(self) (assert(PyBytes_Check(self)),((PyBytesObject *)(self))->ob_bytes)
#define PyBytes_GET_SIZE(self) (assert(PyBytes_Check(self)),Py_SIZE(self))
#define PyByteArray_AS_STRING(self) (assert(PyByteArray_Check(self)),((PyByteArrayObject *)(self))->ob_bytes)
#define PyByteArray_GET_SIZE(self) (assert(PyByteArray_Check(self)),Py_SIZE(self))
#ifdef __cplusplus
}

View File

@ -126,7 +126,7 @@ PyAPI_FUNC(void) _PyExc_Init(void);
PyAPI_FUNC(void) _PyImportHooks_Init(void);
PyAPI_FUNC(int) _PyFrame_Init(void);
PyAPI_FUNC(void) _PyFloat_Init(void);
PyAPI_FUNC(int) PyBytes_Init(void);
PyAPI_FUNC(int) PyByteArray_Init(void);
/* Various internal finalizers */
PyAPI_FUNC(void) _PyExc_Fini(void);
@ -139,7 +139,7 @@ PyAPI_FUNC(void) PyTuple_Fini(void);
PyAPI_FUNC(void) PyList_Fini(void);
PyAPI_FUNC(void) PySet_Fini(void);
PyAPI_FUNC(void) PyString_Fini(void);
PyAPI_FUNC(void) PyBytes_Fini(void);
PyAPI_FUNC(void) PyByteArray_Fini(void);
PyAPI_FUNC(void) PyFloat_Fini(void);
PyAPI_FUNC(void) PyOS_FiniInterrupts(void);

View File

@ -1174,14 +1174,14 @@ _db_associateCallback(DB* db, const DBT* priKey, const DBT* priData,
else if (PyLong_Check(result)) {
retval = PyLong_AsLong(result);
}
else if (PyBytes_Check(result) || PyString_Check(result)) {
else if (PyByteArray_Check(result) || PyString_Check(result)) {
char* data;
Py_ssize_t size;
CLEAR_DBT(*secKey);
size = Py_SIZE(result);
if (PyBytes_Check(result))
data = PyBytes_AS_STRING(result);
if (PyByteArray_Check(result))
data = PyByteArray_AS_STRING(result);
else
data = PyString_AS_STRING(result);
secKey->flags = DB_DBT_APPMALLOC; /* DB will free */

View File

@ -1596,7 +1596,7 @@ c_void_p_from_param(PyObject *type, PyObject *value)
return (PyObject *)parg;
}
/* bytes */
if (PyBytes_Check(value)) {
if (PyByteArray_Check(value)) {
PyCArgObject *parg;
struct fielddesc *fd = getentry("z");

View File

@ -1172,8 +1172,8 @@ c_set(void *ptr, PyObject *value, Py_ssize_t size)
*(char *)ptr = PyString_AS_STRING(value)[0];
_RET(value);
}
if (PyBytes_Check(value) && PyBytes_GET_SIZE(value) == 1) {
*(char *)ptr = PyBytes_AS_STRING(value)[0];
if (PyByteArray_Check(value) && PyByteArray_GET_SIZE(value) == 1) {
*(char *)ptr = PyByteArray_AS_STRING(value)[0];
_RET(value);
}
if (PyLong_Check(value))

View File

@ -111,7 +111,7 @@ dbm_subscript(dbmobject *dp, register PyObject *key)
PyErr_SetString(DbmError, "");
return NULL;
}
return PyBytes_FromStringAndSize(drec.dptr, drec.dsize);
return PyByteArray_FromStringAndSize(drec.dptr, drec.dsize);
}
static int
@ -188,7 +188,7 @@ dbm_keys(register dbmobject *dp, PyObject *unused)
return NULL;
for (key = dbm_firstkey(dp->di_dbm); key.dptr;
key = dbm_nextkey(dp->di_dbm)) {
item = PyBytes_FromStringAndSize(key.dptr, key.dsize);
item = PyByteArray_FromStringAndSize(key.dptr, key.dsize);
if (item == NULL) {
Py_DECREF(v);
return NULL;
@ -260,7 +260,7 @@ dbm_get(register dbmobject *dp, PyObject *args)
check_dbmobject_open(dp);
val = dbm_fetch(dp->di_dbm, key);
if (val.dptr != NULL)
return PyBytes_FromStringAndSize(val.dptr, val.dsize);
return PyByteArray_FromStringAndSize(val.dptr, val.dsize);
else {
Py_INCREF(defvalue);
return defvalue;
@ -283,9 +283,9 @@ dbm_setdefault(register dbmobject *dp, PyObject *args)
check_dbmobject_open(dp);
val = dbm_fetch(dp->di_dbm, key);
if (val.dptr != NULL)
return PyBytes_FromStringAndSize(val.dptr, val.dsize);
return PyByteArray_FromStringAndSize(val.dptr, val.dsize);
if (defvalue == NULL) {
defvalue = PyBytes_FromStringAndSize(NULL, 0);
defvalue = PyByteArray_FromStringAndSize(NULL, 0);
if (defvalue == NULL)
return NULL;
val.dptr = NULL;

View File

@ -352,7 +352,7 @@ PyObject* _pysqlite_fetch_one_row(pysqlite_Cursor* self)
}
PyOS_snprintf(buf, sizeof(buf) - 1, "Could not decode to UTF-8 column '%s' with text '%s'",
colname , val_str);
buf_bytes = PyBytes_FromStringAndSize(buf, strlen(buf));
buf_bytes = PyByteArray_FromStringAndSize(buf, strlen(buf));
if (!buf_bytes) {
PyErr_SetString(pysqlite_OperationalError, "Could not decode to UTF-8");
} else {
@ -368,8 +368,8 @@ PyObject* _pysqlite_fetch_one_row(pysqlite_Cursor* self)
}
} else if (self->connection->text_factory == (PyObject*)&PyString_Type) {
converted = PyString_FromString(val_str);
} else if (self->connection->text_factory == (PyObject*)&PyBytes_Type) {
converted = PyBytes_FromStringAndSize(val_str, strlen(val_str));
} else if (self->connection->text_factory == (PyObject*)&PyByteArray_Type) {
converted = PyByteArray_FromStringAndSize(val_str, strlen(val_str));
} else {
converted = PyObject_CallFunction(self->connection->text_factory, "y", val_str);
}

View File

@ -137,7 +137,7 @@ static PyObject* module_register_adapter(PyObject* self, PyObject* args, PyObjec
/* a basic type is adapted; there's a performance optimization if that's not the case
* (99 % of all usages) */
if (type == &PyLong_Type || type == &PyFloat_Type
|| type == &PyUnicode_Type || type == &PyBytes_Type) {
|| type == &PyUnicode_Type || type == &PyByteArray_Type) {
pysqlite_BaseTypeAdapted = 1;
}

View File

@ -167,7 +167,7 @@ static int _need_adapt(PyObject* obj)
}
if (PyLong_CheckExact(obj) || PyFloat_CheckExact(obj)
|| PyUnicode_CheckExact(obj) || PyBytes_CheckExact(obj)) {
|| PyUnicode_CheckExact(obj) || PyByteArray_CheckExact(obj)) {
return 0;
} else {
return 1;

View File

@ -1263,16 +1263,16 @@ static PyObject *PySSL_SSLread(PySSLObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "|Oi:read", &buf, &count))
return NULL;
if ((buf == NULL) || (buf == Py_None)) {
if (!(buf = PyBytes_FromStringAndSize((char *) 0, len)))
if (!(buf = PyByteArray_FromStringAndSize((char *) 0, len)))
return NULL;
} else if (PyLong_Check(buf)) {
len = PyLong_AS_LONG(buf);
if (!(buf = PyBytes_FromStringAndSize((char *) 0, len)))
if (!(buf = PyByteArray_FromStringAndSize((char *) 0, len)))
return NULL;
} else {
if (!PyBytes_Check(buf))
if (!PyByteArray_Check(buf))
return NULL;
len = PyBytes_Size(buf);
len = PyByteArray_Size(buf);
if ((count > 0) && (count <= len))
len = count;
buf_passed = 1;
@ -1313,7 +1313,7 @@ static PyObject *PySSL_SSLread(PySSLObject *self, PyObject *args)
do {
err = 0;
PySSL_BEGIN_ALLOW_THREADS
count = SSL_read(self->ssl, PyBytes_AsString(buf), len);
count = SSL_read(self->ssl, PyByteArray_AsString(buf), len);
err = SSL_get_error(self->ssl, count);
PySSL_END_ALLOW_THREADS
if(PyErr_CheckSignals()) {
@ -1357,7 +1357,7 @@ static PyObject *PySSL_SSLread(PySSLObject *self, PyObject *args)
done:
if (!buf_passed) {
PyObject *res = PyString_FromStringAndSize(
PyBytes_AS_STRING(buf), count);
PyByteArray_AS_STRING(buf), count);
Py_DECREF(buf);
return res;
} else {

View File

@ -1646,7 +1646,7 @@ s_pack_internal(PyStructObject *soself, PyObject *args, int offset, char* buf)
return -1;
}
isstring = PyString_Check(v);
if (!isstring && !PyBytes_Check(v)) {
if (!isstring && !PyByteArray_Check(v)) {
PyErr_SetString(StructError,
"argument for 's' must be a string");
return -1;
@ -1656,8 +1656,8 @@ s_pack_internal(PyStructObject *soself, PyObject *args, int offset, char* buf)
p = PyString_AS_STRING(v);
}
else {
n = PyBytes_GET_SIZE(v);
p = PyBytes_AS_STRING(v);
n = PyByteArray_GET_SIZE(v);
p = PyByteArray_AS_STRING(v);
}
if (n > code->size)
n = code->size;
@ -1672,7 +1672,7 @@ s_pack_internal(PyStructObject *soself, PyObject *args, int offset, char* buf)
return -1;
}
isstring = PyString_Check(v);
if (!isstring && !PyBytes_Check(v)) {
if (!isstring && !PyByteArray_Check(v)) {
PyErr_SetString(StructError,
"argument for 'p' must be a string");
return -1;
@ -1682,8 +1682,8 @@ s_pack_internal(PyStructObject *soself, PyObject *args, int offset, char* buf)
p = PyString_AS_STRING(v);
}
else {
n = PyBytes_GET_SIZE(v);
p = PyBytes_AS_STRING(v);
n = PyByteArray_GET_SIZE(v);
p = PyByteArray_AS_STRING(v);
}
if (n > (code->size - 1))
n = code->size - 1;

View File

@ -1855,7 +1855,7 @@ array_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return NULL;
if (!(initial == NULL || PyList_Check(initial)
|| PyBytes_Check(initial)
|| PyByteArray_Check(initial)
|| PyString_Check(initial)
|| PyTuple_Check(initial)
|| ((c=='u') && PyUnicode_Check(initial)))) {
@ -1901,7 +1901,7 @@ array_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Py_DECREF(v);
}
}
else if (initial != NULL && (PyBytes_Check(initial) ||
else if (initial != NULL && (PyByteArray_Check(initial) ||
PyString_Check(initial))) {
PyObject *t_initial, *v;
t_initial = PyTuple_Pack(1, initial);

View File

@ -228,7 +228,7 @@ mmap_read_line_method(mmap_object *self,
else
++eol; /* we're interested in the position after the
newline. */
result = PyBytes_FromStringAndSize(start, (eol - start));
result = PyByteArray_FromStringAndSize(start, (eol - start));
self->pos += (eol - start);
return result;
}
@ -248,7 +248,7 @@ mmap_read_method(mmap_object *self,
if ((self->pos + num_bytes) > self->size) {
num_bytes -= (self->pos+num_bytes) - self->size;
}
result = PyBytes_FromStringAndSize(self->data+self->pos, num_bytes);
result = PyByteArray_FromStringAndSize(self->data+self->pos, num_bytes);
self->pos += num_bytes;
return result;
}
@ -679,7 +679,7 @@ mmap_item(mmap_object *self, Py_ssize_t i)
PyErr_SetString(PyExc_IndexError, "mmap index out of range");
return NULL;
}
return PyBytes_FromStringAndSize(self->data + i, 1);
return PyByteArray_FromStringAndSize(self->data + i, 1);
}
static PyObject *
@ -769,14 +769,14 @@ mmap_ass_item(mmap_object *self, Py_ssize_t i, PyObject *v)
"mmap object doesn't support item deletion");
return -1;
}
if (! (PyBytes_Check(v) && PyBytes_Size(v)==1) ) {
if (! (PyByteArray_Check(v) && PyByteArray_Size(v)==1) ) {
PyErr_SetString(PyExc_IndexError,
"mmap assignment must be length-1 bytes()");
return -1;
}
if (!is_writable(self))
return -1;
buf = PyBytes_AsString(v);
buf = PyByteArray_AsString(v);
self->data[i] = buf[0];
return 0;
}

View File

@ -366,10 +366,10 @@ oss_read(oss_audio_t *self, PyObject *args)
if (!PyArg_ParseTuple(args, "i:read", &size))
return NULL;
rv = PyBytes_FromStringAndSize(NULL, size);
rv = PyByteArray_FromStringAndSize(NULL, size);
if (rv == NULL)
return NULL;
cp = PyBytes_AS_STRING(rv);
cp = PyByteArray_AS_STRING(rv);
Py_BEGIN_ALLOW_THREADS
count = read(self->fd, cp, size);
@ -381,7 +381,7 @@ oss_read(oss_audio_t *self, PyObject *args)
return NULL;
}
self->icount += count;
PyBytes_Resize(rv, count);
PyByteArray_Resize(rv, count);
return rv;
}

View File

@ -866,8 +866,8 @@ readinst(char *buf, int buf_size, PyObject *meth)
if (PyString_Check(str))
ptr = PyString_AS_STRING(str);
else if (PyBytes_Check(str))
ptr = PyBytes_AS_STRING(str);
else if (PyByteArray_Check(str))
ptr = PyByteArray_AS_STRING(str);
else {
PyErr_Format(PyExc_TypeError,
"read() did not return a bytes object (type=%.400s)",

View File

@ -467,7 +467,7 @@ zipimporter_get_source(PyObject *obj, PyObject *args)
toc_entry = PyDict_GetItemString(self->files, path);
if (toc_entry != NULL) {
PyObject *bytes = get_data(PyUnicode_AsString(self->archive), toc_entry);
PyObject *res = PyUnicode_FromString(PyBytes_AsString(bytes));
PyObject *res = PyUnicode_FromString(PyByteArray_AsString(bytes));
Py_XDECREF(bytes);
return res;
}
@ -836,13 +836,13 @@ get_data(char *archive, PyObject *toc_entry)
bytes_size = compress == 0 ? data_size : data_size + 1;
if (bytes_size == 0)
bytes_size++;
raw_data = PyBytes_FromStringAndSize((char *)NULL, bytes_size);
raw_data = PyByteArray_FromStringAndSize((char *)NULL, bytes_size);
if (raw_data == NULL) {
fclose(fp);
return NULL;
}
buf = PyBytes_AsString(raw_data);
buf = PyByteArray_AsString(raw_data);
err = fseek(fp, file_offset, 0);
if (err == 0)
@ -862,7 +862,7 @@ get_data(char *archive, PyObject *toc_entry)
buf[data_size] = '\0';
if (compress == 0) { /* data is not compressed */
data = PyBytes_FromStringAndSize(buf, data_size);
data = PyByteArray_FromStringAndSize(buf, data_size);
Py_DECREF(raw_data);
return data;
}
@ -903,8 +903,8 @@ static PyObject *
unmarshal_code(char *pathname, PyObject *data, time_t mtime)
{
PyObject *code;
char *buf = PyBytes_AsString(data);
Py_ssize_t size = PyBytes_Size(data);
char *buf = PyByteArray_AsString(data);
Py_ssize_t size = PyByteArray_Size(data);
if (size <= 9) {
PyErr_SetString(ZipImportError,
@ -949,16 +949,16 @@ unmarshal_code(char *pathname, PyObject *data, time_t mtime)
static PyObject *
normalize_line_endings(PyObject *source)
{
char *buf, *q, *p = PyBytes_AsString(source);
char *buf, *q, *p = PyByteArray_AsString(source);
PyObject *fixed_source;
int len = 0;
if (!p) {
return PyBytes_FromStringAndSize("\n\0", 2);
return PyByteArray_FromStringAndSize("\n\0", 2);
}
/* one char extra for trailing \n and one for terminating \0 */
buf = (char *)PyMem_Malloc(PyBytes_Size(source) + 2);
buf = (char *)PyMem_Malloc(PyByteArray_Size(source) + 2);
if (buf == NULL) {
PyErr_SetString(PyExc_MemoryError,
"zipimport: no memory to allocate "
@ -978,7 +978,7 @@ normalize_line_endings(PyObject *source)
}
*q++ = '\n'; /* add trailing \n */
*q = '\0';
fixed_source = PyBytes_FromStringAndSize(buf, len + 2);
fixed_source = PyByteArray_FromStringAndSize(buf, len + 2);
PyMem_Free(buf);
return fixed_source;
}
@ -994,7 +994,7 @@ compile_source(char *pathname, PyObject *source)
if (fixed_source == NULL)
return NULL;
code = Py_CompileString(PyBytes_AsString(fixed_source), pathname,
code = Py_CompileString(PyByteArray_AsString(fixed_source), pathname,
Py_file_input);
Py_DECREF(fixed_source);
return code;

View File

@ -96,12 +96,12 @@ newcompobject(PyTypeObject *type)
if (self == NULL)
return NULL;
self->is_initialised = 0;
self->unused_data = PyBytes_FromStringAndSize("", 0);
self->unused_data = PyByteArray_FromStringAndSize("", 0);
if (self->unused_data == NULL) {
Py_DECREF(self);
return NULL;
}
self->unconsumed_tail = PyBytes_FromStringAndSize("", 0);
self->unconsumed_tail = PyByteArray_FromStringAndSize("", 0);
if (self->unconsumed_tail == NULL) {
Py_DECREF(self);
return NULL;
@ -174,7 +174,7 @@ PyZlib_compress(PyObject *self, PyObject *args)
err=deflateEnd(&zst);
if (err == Z_OK)
ReturnVal = PyBytes_FromStringAndSize((char *)output,
ReturnVal = PyByteArray_FromStringAndSize((char *)output,
zst.total_out);
else
zlib_error(zst, err, "while finishing compression");
@ -211,12 +211,12 @@ PyZlib_decompress(PyObject *self, PyObject *args)
zst.avail_in = length;
zst.avail_out = r_strlen;
if (!(result_str = PyBytes_FromStringAndSize(NULL, r_strlen)))
if (!(result_str = PyByteArray_FromStringAndSize(NULL, r_strlen)))
return NULL;
zst.zalloc = (alloc_func)NULL;
zst.zfree = (free_func)Z_NULL;
zst.next_out = (Byte *)PyBytes_AS_STRING(result_str);
zst.next_out = (Byte *)PyByteArray_AS_STRING(result_str);
zst.next_in = (Byte *)input;
err = inflateInit2(&zst, wsize);
@ -256,12 +256,12 @@ PyZlib_decompress(PyObject *self, PyObject *args)
/* fall through */
case(Z_OK):
/* need more memory */
if (PyBytes_Resize(result_str, r_strlen << 1) < 0) {
if (PyByteArray_Resize(result_str, r_strlen << 1) < 0) {
inflateEnd(&zst);
goto error;
}
zst.next_out =
(unsigned char *)PyBytes_AS_STRING(result_str) + r_strlen;
(unsigned char *)PyByteArray_AS_STRING(result_str) + r_strlen;
zst.avail_out = r_strlen;
r_strlen = r_strlen << 1;
break;
@ -278,7 +278,7 @@ PyZlib_decompress(PyObject *self, PyObject *args)
goto error;
}
if (PyBytes_Resize(result_str, zst.total_out) < 0)
if (PyByteArray_Resize(result_str, zst.total_out) < 0)
goto error;
return result_str;
@ -402,7 +402,7 @@ PyZlib_objcompress(compobject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "s#:compress", &input, &inplen))
return NULL;
if (!(RetVal = PyBytes_FromStringAndSize(NULL, length)))
if (!(RetVal = PyByteArray_FromStringAndSize(NULL, length)))
return NULL;
ENTER_ZLIB
@ -411,7 +411,7 @@ PyZlib_objcompress(compobject *self, PyObject *args)
self->zst.avail_in = inplen;
self->zst.next_in = input;
self->zst.avail_out = length;
self->zst.next_out = (unsigned char *)PyBytes_AS_STRING(RetVal);
self->zst.next_out = (unsigned char *)PyByteArray_AS_STRING(RetVal);
Py_BEGIN_ALLOW_THREADS
err = deflate(&(self->zst), Z_NO_FLUSH);
@ -420,13 +420,13 @@ PyZlib_objcompress(compobject *self, PyObject *args)
/* while Z_OK and the output buffer is full, there might be more output,
so extend the output buffer and try again */
while (err == Z_OK && self->zst.avail_out == 0) {
if (PyBytes_Resize(RetVal, length << 1) < 0) {
if (PyByteArray_Resize(RetVal, length << 1) < 0) {
Py_DECREF(RetVal);
RetVal = NULL;
goto error;
}
self->zst.next_out =
(unsigned char *)PyBytes_AS_STRING(RetVal) + length;
(unsigned char *)PyByteArray_AS_STRING(RetVal) + length;
self->zst.avail_out = length;
length = length << 1;
@ -445,7 +445,7 @@ PyZlib_objcompress(compobject *self, PyObject *args)
RetVal = NULL;
goto error;
}
if (PyBytes_Resize(RetVal, self->zst.total_out - start_total_out) < 0) {
if (PyByteArray_Resize(RetVal, self->zst.total_out - start_total_out) < 0) {
Py_DECREF(RetVal);
RetVal = NULL;
}
@ -487,7 +487,7 @@ PyZlib_objdecompress(compobject *self, PyObject *args)
/* limit amount of data allocated to max_length */
if (max_length && length > max_length)
length = max_length;
if (!(RetVal = PyBytes_FromStringAndSize(NULL, length)))
if (!(RetVal = PyByteArray_FromStringAndSize(NULL, length)))
return NULL;
ENTER_ZLIB
@ -496,7 +496,7 @@ PyZlib_objdecompress(compobject *self, PyObject *args)
self->zst.avail_in = inplen;
self->zst.next_in = input;
self->zst.avail_out = length;
self->zst.next_out = (unsigned char *)PyBytes_AS_STRING(RetVal);
self->zst.next_out = (unsigned char *)PyByteArray_AS_STRING(RetVal);
Py_BEGIN_ALLOW_THREADS
err = inflate(&(self->zst), Z_SYNC_FLUSH);
@ -518,13 +518,13 @@ PyZlib_objdecompress(compobject *self, PyObject *args)
if (max_length && length > max_length)
length = max_length;
if (PyBytes_Resize(RetVal, length) < 0) {
if (PyByteArray_Resize(RetVal, length) < 0) {
Py_DECREF(RetVal);
RetVal = NULL;
goto error;
}
self->zst.next_out =
(unsigned char *)PyBytes_AS_STRING(RetVal) + old_length;
(unsigned char *)PyByteArray_AS_STRING(RetVal) + old_length;
self->zst.avail_out = length - old_length;
Py_BEGIN_ALLOW_THREADS
@ -536,7 +536,7 @@ PyZlib_objdecompress(compobject *self, PyObject *args)
of specified size. Return the unconsumed tail in an attribute.*/
if(max_length) {
Py_DECREF(self->unconsumed_tail);
self->unconsumed_tail = PyBytes_FromStringAndSize((char *)self->zst.next_in,
self->unconsumed_tail = PyByteArray_FromStringAndSize((char *)self->zst.next_in,
self->zst.avail_in);
if(!self->unconsumed_tail) {
Py_DECREF(RetVal);
@ -553,7 +553,7 @@ PyZlib_objdecompress(compobject *self, PyObject *args)
*/
if (err == Z_STREAM_END) {
Py_XDECREF(self->unused_data); /* Free original empty string */
self->unused_data = PyBytes_FromStringAndSize(
self->unused_data = PyByteArray_FromStringAndSize(
(char *)self->zst.next_in, self->zst.avail_in);
if (self->unused_data == NULL) {
Py_DECREF(RetVal);
@ -570,7 +570,7 @@ PyZlib_objdecompress(compobject *self, PyObject *args)
goto error;
}
if (PyBytes_Resize(RetVal, self->zst.total_out - start_total_out) < 0) {
if (PyByteArray_Resize(RetVal, self->zst.total_out - start_total_out) < 0) {
Py_DECREF(RetVal);
RetVal = NULL;
}
@ -603,10 +603,10 @@ PyZlib_flush(compobject *self, PyObject *args)
/* Flushing with Z_NO_FLUSH is a no-op, so there's no point in
doing any work at all; just return an empty string. */
if (flushmode == Z_NO_FLUSH) {
return PyBytes_FromStringAndSize(NULL, 0);
return PyByteArray_FromStringAndSize(NULL, 0);
}
if (!(RetVal = PyBytes_FromStringAndSize(NULL, length)))
if (!(RetVal = PyByteArray_FromStringAndSize(NULL, length)))
return NULL;
ENTER_ZLIB
@ -614,7 +614,7 @@ PyZlib_flush(compobject *self, PyObject *args)
start_total_out = self->zst.total_out;
self->zst.avail_in = 0;
self->zst.avail_out = length;
self->zst.next_out = (unsigned char *)PyBytes_AS_STRING(RetVal);
self->zst.next_out = (unsigned char *)PyByteArray_AS_STRING(RetVal);
Py_BEGIN_ALLOW_THREADS
err = deflate(&(self->zst), flushmode);
@ -623,13 +623,13 @@ PyZlib_flush(compobject *self, PyObject *args)
/* while Z_OK and the output buffer is full, there might be more output,
so extend the output buffer and try again */
while (err == Z_OK && self->zst.avail_out == 0) {
if (PyBytes_Resize(RetVal, length << 1) < 0) {
if (PyByteArray_Resize(RetVal, length << 1) < 0) {
Py_DECREF(RetVal);
RetVal = NULL;
goto error;
}
self->zst.next_out =
(unsigned char *)PyBytes_AS_STRING(RetVal) + length;
(unsigned char *)PyByteArray_AS_STRING(RetVal) + length;
self->zst.avail_out = length;
length = length << 1;
@ -663,7 +663,7 @@ PyZlib_flush(compobject *self, PyObject *args)
goto error;
}
if (PyBytes_Resize(RetVal, self->zst.total_out - start_total_out) < 0) {
if (PyByteArray_Resize(RetVal, self->zst.total_out - start_total_out) < 0) {
Py_DECREF(RetVal);
RetVal = NULL;
}
@ -798,7 +798,7 @@ PyZlib_unflush(compobject *self, PyObject *args)
PyErr_SetString(PyExc_ValueError, "length must be greater than zero");
return NULL;
}
if (!(retval = PyBytes_FromStringAndSize(NULL, length)))
if (!(retval = PyByteArray_FromStringAndSize(NULL, length)))
return NULL;
@ -806,7 +806,7 @@ PyZlib_unflush(compobject *self, PyObject *args)
start_total_out = self->zst.total_out;
self->zst.avail_out = length;
self->zst.next_out = (Byte *)PyBytes_AS_STRING(retval);
self->zst.next_out = (Byte *)PyByteArray_AS_STRING(retval);
Py_BEGIN_ALLOW_THREADS
err = inflate(&(self->zst), Z_FINISH);
@ -815,12 +815,12 @@ PyZlib_unflush(compobject *self, PyObject *args)
/* while Z_OK and the output buffer is full, there might be more output,
so extend the output buffer and try again */
while ((err == Z_OK || err == Z_BUF_ERROR) && self->zst.avail_out == 0) {
if (PyBytes_Resize(retval, length << 1) < 0) {
if (PyByteArray_Resize(retval, length << 1) < 0) {
Py_DECREF(retval);
retval = NULL;
goto error;
}
self->zst.next_out = (Byte *)PyBytes_AS_STRING(retval) + length;
self->zst.next_out = (Byte *)PyByteArray_AS_STRING(retval) + length;
self->zst.avail_out = length;
length = length << 1;
@ -842,7 +842,7 @@ PyZlib_unflush(compobject *self, PyObject *args)
goto error;
}
}
if (PyBytes_Resize(retval, self->zst.total_out - start_total_out) < 0) {
if (PyByteArray_Resize(retval, self->zst.total_out - start_total_out) < 0) {
Py_DECREF(retval);
retval = NULL;
}

File diff suppressed because it is too large Load Diff

View File

@ -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) {

View File

@ -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 */

View File

@ -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)

View File

@ -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;
}

View File

@ -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);

View File

@ -908,7 +908,7 @@ Reg2Py(BYTE *retDataBuf, DWORD retDataSize, DWORD typ)
obData = Py_None;
}
else
obData = PyBytes_FromStringAndSize(
obData = PyByteArray_FromStringAndSize(
(char *)retDataBuf, retDataSize);
break;
}

View File

@ -360,7 +360,7 @@ check_bom(int get_char(struct tok_state *),
1) NULL: need to call tok->decoding_readline to get a new line
2) PyUnicodeObject *: decoding_feof has called tok->decoding_readline and
stored the result in tok->decoding_buffer
3) PyBytesObject *: previous call to fp_readl did not have enough room
3) PyByteArrayObject *: previous call to fp_readl did not have enough room
(in the s buffer) to copy entire contents of the line read
by tok->decoding_readline. tok->decoding_buffer has the overflow.
In this case, fp_readl is called in a loop (with an expanded buffer)
@ -398,17 +398,17 @@ fp_readl(char *s, int size, struct tok_state *tok)
}
else
{
buf = PyBytes_AsString(bufobj);
buf = PyByteArray_AsString(bufobj);
if (buf == NULL) {
goto error;
}
buflen = PyBytes_GET_SIZE(bufobj);
buflen = PyByteArray_GET_SIZE(bufobj);
}
Py_XDECREF(tok->decoding_buffer);
if (buflen > size) {
/* Too many chars, the rest goes into tok->decoding_buffer */
tok->decoding_buffer = PyBytes_FromStringAndSize(buf+size,
tok->decoding_buffer = PyByteArray_FromStringAndSize(buf+size,
buflen-size);
if (tok->decoding_buffer == NULL)
goto error;

View File

@ -1377,11 +1377,11 @@ builtin_ord(PyObject *self, PyObject* obj)
}
#endif
}
else if (PyBytes_Check(obj)) {
else if (PyByteArray_Check(obj)) {
/* XXX Hopefully this is temporary */
size = PyBytes_GET_SIZE(obj);
size = PyByteArray_GET_SIZE(obj);
if (size == 1) {
ord = (long)((unsigned char)*PyBytes_AS_STRING(obj));
ord = (long)((unsigned char)*PyByteArray_AS_STRING(obj));
return PyLong_FromLong(ord);
}
}
@ -1823,7 +1823,7 @@ builtin_sum(PyObject *self, PyObject *args)
Py_DECREF(iter);
return NULL;
}
if (PyBytes_Check(result)) {
if (PyByteArray_Check(result)) {
PyErr_SetString(PyExc_TypeError,
"sum() can't sum bytes [use b''.join(seq) instead]");
Py_DECREF(iter);
@ -2266,7 +2266,7 @@ _PyBuiltin_Init(void)
SETBUILTIN("True", Py_True);
SETBUILTIN("bool", &PyBool_Type);
SETBUILTIN("memoryview", &PyMemoryView_Type);
SETBUILTIN("bytearray", &PyBytes_Type);
SETBUILTIN("bytearray", &PyByteArray_Type);
SETBUILTIN("bytes", &PyString_Type);
SETBUILTIN("classmethod", &PyClassMethod_Type);
#ifndef WITHOUT_COMPLEX

View File

@ -345,7 +345,7 @@ PyObject *PyCodec_Encode(PyObject *object,
goto onError;
}
v = PyTuple_GET_ITEM(result, 0);
if (PyBytes_Check(v)) {
if (PyByteArray_Check(v)) {
char msg[100];
PyOS_snprintf(msg, sizeof(msg),
"encoder %s returned buffer instead of bytes",
@ -354,7 +354,7 @@ PyObject *PyCodec_Encode(PyObject *object,
v = NULL;
goto onError;
}
v = PyString_FromStringAndSize(PyBytes_AS_STRING(v), Py_SIZE(v));
v = PyString_FromStringAndSize(PyByteArray_AS_STRING(v), Py_SIZE(v));
}
else if (PyString_Check(v))
Py_INCREF(v);

View File

@ -971,7 +971,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
/* Encode object */
if (!recode_strings &&
(PyString_Check(arg) || PyBytes_Check(arg))) {
(PyString_Check(arg) || PyByteArray_Check(arg))) {
s = arg;
Py_INCREF(s);
if (PyObject_AsCharBuffer(s, &ptr, &size) < 0)
@ -1123,9 +1123,9 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
break;
}
case 'Y': { /* PyBytes object */
case 'Y': { /* PyByteArray object */
PyObject **p = va_arg(*p_va, PyObject **);
if (PyBytes_Check(arg))
if (PyByteArray_Check(arg))
*p = arg;
else
return converterr("buffer", arg, msgbuf, bufsize);

View File

@ -1095,7 +1095,7 @@ PyMarshal_WriteObjectToString(PyObject *x, int version)
}
if (wf.str != NULL) {
/* XXX Quick hack -- need to do this differently */
res = PyBytes_FromObject(wf.str);
res = PyByteArray_FromObject(wf.str);
Py_DECREF(wf.str);
}
return res;
@ -1136,9 +1136,9 @@ marshal_load(PyObject *self, PyObject *f)
rf.ptr = PyString_AS_STRING(data);
rf.end = rf.ptr + PyString_GET_SIZE(data);
}
else if (PyBytes_Check(data)) {
rf.ptr = PyBytes_AS_STRING(data);
rf.end = rf.ptr + PyBytes_GET_SIZE(data);
else if (PyByteArray_Check(data)) {
rf.ptr = PyByteArray_AS_STRING(data);
rf.end = rf.ptr + PyByteArray_GET_SIZE(data);
}
else {
PyErr_Format(PyExc_TypeError,

View File

@ -175,7 +175,7 @@ Py_InitializeEx(int install_sigs)
if (!_PyLong_Init())
Py_FatalError("Py_Initialize: can't init longs");
if (!PyBytes_Init())
if (!PyByteArray_Init())
Py_FatalError("Py_Initialize: can't init bytes");
_PyFloat_Init();
@ -460,7 +460,7 @@ Py_Finalize(void)
PyList_Fini();
PySet_Fini();
PyString_Fini();
PyBytes_Fini();
PyByteArray_Fini();
PyLong_Fini();
PyFloat_Fini();
PyDict_Fini();