[Python-3000-checkins] r59650 - in python/branches/py3k-grandrenaming: Include/bytesobject.h Include/pythonrun.h Modules/_bsddb.c Modules/_ctypes/_ctypes.c Modules/_ctypes/cfield.c Modules/_sqlite/cursor.c Modules/_ssl.c Modules/_struct.c Modules/arraymodule.c Modules/dbmmodule.c Modules/gdbmmodule.c Modules/mmapmodule.c Modules/ossaudiodev.c Modules/pyexpat.c Modules/zipimport.c Modules/zlibmodule.c Objects/bytesobject.c Objects/longobject.c Objects/memoryobject.c Objects/object.c Objects/stringobject.c Objects/unicodeobject.c PC/_winreg.c Parser/tokenizer.c Python/bltinmodule.c Python/codecs.c Python/getargs.c Python/import.c Python/mactoolboxglue.c Python/marshal.c Python/pythonrun.c
christian.heimes
python-3000-checkins at python.org
Tue Jan 1 20:14:45 CET 2008
Author: christian.heimes
Date: Tue Jan 1 20:14:44 2008
New Revision: 59650
Modified:
python/branches/py3k-grandrenaming/Include/bytesobject.h
python/branches/py3k-grandrenaming/Include/pythonrun.h
python/branches/py3k-grandrenaming/Modules/_bsddb.c
python/branches/py3k-grandrenaming/Modules/_ctypes/_ctypes.c
python/branches/py3k-grandrenaming/Modules/_ctypes/cfield.c
python/branches/py3k-grandrenaming/Modules/_sqlite/cursor.c
python/branches/py3k-grandrenaming/Modules/_ssl.c
python/branches/py3k-grandrenaming/Modules/_struct.c
python/branches/py3k-grandrenaming/Modules/arraymodule.c
python/branches/py3k-grandrenaming/Modules/dbmmodule.c
python/branches/py3k-grandrenaming/Modules/gdbmmodule.c
python/branches/py3k-grandrenaming/Modules/mmapmodule.c
python/branches/py3k-grandrenaming/Modules/ossaudiodev.c
python/branches/py3k-grandrenaming/Modules/pyexpat.c
python/branches/py3k-grandrenaming/Modules/zipimport.c
python/branches/py3k-grandrenaming/Modules/zlibmodule.c
python/branches/py3k-grandrenaming/Objects/bytesobject.c
python/branches/py3k-grandrenaming/Objects/longobject.c
python/branches/py3k-grandrenaming/Objects/memoryobject.c
python/branches/py3k-grandrenaming/Objects/object.c
python/branches/py3k-grandrenaming/Objects/stringobject.c
python/branches/py3k-grandrenaming/Objects/unicodeobject.c
python/branches/py3k-grandrenaming/PC/_winreg.c
python/branches/py3k-grandrenaming/Parser/tokenizer.c
python/branches/py3k-grandrenaming/Python/bltinmodule.c
python/branches/py3k-grandrenaming/Python/codecs.c
python/branches/py3k-grandrenaming/Python/getargs.c
python/branches/py3k-grandrenaming/Python/import.c
python/branches/py3k-grandrenaming/Python/mactoolboxglue.c
python/branches/py3k-grandrenaming/Python/marshal.c
python/branches/py3k-grandrenaming/Python/pythonrun.c
Log:
find -name '*.c' -or -name '*.h' -or -name '*.rst' | xargs sed -i s/PyBytes_/PyByteArray_/g
Modified: python/branches/py3k-grandrenaming/Include/bytesobject.h
==============================================================================
--- python/branches/py3k-grandrenaming/Include/bytesobject.h (original)
+++ python/branches/py3k-grandrenaming/Include/bytesobject.h Tue Jan 1 20:14:44 2008
@@ -28,24 +28,24 @@
} PyBytesObject;
/* Type object */
-PyAPI_DATA(PyTypeObject) PyBytes_Type;
+PyAPI_DATA(PyTypeObject) PyByteArray_Type;
PyAPI_DATA(PyTypeObject) PyBytesIter_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)),((PyBytesObject *)(self))->ob_bytes)
+#define PyByteArray_GET_SIZE(self) (assert(PyByteArray_Check(self)),Py_SIZE(self))
#ifdef __cplusplus
}
Modified: python/branches/py3k-grandrenaming/Include/pythonrun.h
==============================================================================
--- python/branches/py3k-grandrenaming/Include/pythonrun.h (original)
+++ python/branches/py3k-grandrenaming/Include/pythonrun.h Tue Jan 1 20:14:44 2008
@@ -126,7 +126,7 @@
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);
@@ -138,7 +138,7 @@
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);
Modified: python/branches/py3k-grandrenaming/Modules/_bsddb.c
==============================================================================
--- python/branches/py3k-grandrenaming/Modules/_bsddb.c (original)
+++ python/branches/py3k-grandrenaming/Modules/_bsddb.c Tue Jan 1 20:14:44 2008
@@ -1171,14 +1171,14 @@
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 */
Modified: python/branches/py3k-grandrenaming/Modules/_ctypes/_ctypes.c
==============================================================================
--- python/branches/py3k-grandrenaming/Modules/_ctypes/_ctypes.c (original)
+++ python/branches/py3k-grandrenaming/Modules/_ctypes/_ctypes.c Tue Jan 1 20:14:44 2008
@@ -1284,7 +1284,7 @@
return (PyObject *)parg;
}
/* bytes */
- if (PyBytes_Check(value)) {
+ if (PyByteArray_Check(value)) {
PyCArgObject *parg;
struct fielddesc *fd = getentry("z");
Modified: python/branches/py3k-grandrenaming/Modules/_ctypes/cfield.c
==============================================================================
--- python/branches/py3k-grandrenaming/Modules/_ctypes/cfield.c (original)
+++ python/branches/py3k-grandrenaming/Modules/_ctypes/cfield.c Tue Jan 1 20:14:44 2008
@@ -1174,8 +1174,8 @@
*(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))
Modified: python/branches/py3k-grandrenaming/Modules/_sqlite/cursor.c
==============================================================================
--- python/branches/py3k-grandrenaming/Modules/_sqlite/cursor.c (original)
+++ python/branches/py3k-grandrenaming/Modules/_sqlite/cursor.c Tue Jan 1 20:14:44 2008
@@ -367,8 +367,8 @@
}
} 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);
}
Modified: python/branches/py3k-grandrenaming/Modules/_ssl.c
==============================================================================
--- python/branches/py3k-grandrenaming/Modules/_ssl.c (original)
+++ python/branches/py3k-grandrenaming/Modules/_ssl.c Tue Jan 1 20:14:44 2008
@@ -1263,16 +1263,16 @@
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 @@
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 @@
done:
if (!buf_passed) {
PyObject *res = PyString_FromStringAndSize(
- PyBytes_AS_STRING(buf), count);
+ PyByteArray_AS_STRING(buf), count);
Py_DECREF(buf);
return res;
} else {
Modified: python/branches/py3k-grandrenaming/Modules/_struct.c
==============================================================================
--- python/branches/py3k-grandrenaming/Modules/_struct.c (original)
+++ python/branches/py3k-grandrenaming/Modules/_struct.c Tue Jan 1 20:14:44 2008
@@ -1629,7 +1629,7 @@
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;
@@ -1639,8 +1639,8 @@
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;
@@ -1655,7 +1655,7 @@
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;
@@ -1665,8 +1665,8 @@
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;
Modified: python/branches/py3k-grandrenaming/Modules/arraymodule.c
==============================================================================
--- python/branches/py3k-grandrenaming/Modules/arraymodule.c (original)
+++ python/branches/py3k-grandrenaming/Modules/arraymodule.c Tue Jan 1 20:14:44 2008
@@ -1860,7 +1860,7 @@
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)))) {
@@ -1906,7 +1906,7 @@
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);
Modified: python/branches/py3k-grandrenaming/Modules/dbmmodule.c
==============================================================================
--- python/branches/py3k-grandrenaming/Modules/dbmmodule.c (original)
+++ python/branches/py3k-grandrenaming/Modules/dbmmodule.c Tue Jan 1 20:14:44 2008
@@ -111,7 +111,7 @@
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 @@
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 @@
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 @@
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;
Modified: python/branches/py3k-grandrenaming/Modules/gdbmmodule.c
==============================================================================
--- python/branches/py3k-grandrenaming/Modules/gdbmmodule.c (original)
+++ python/branches/py3k-grandrenaming/Modules/gdbmmodule.c Tue Jan 1 20:14:44 2008
@@ -130,7 +130,7 @@
PyErr_SetObject(PyExc_KeyError, key);
return NULL;
}
- v = PyBytes_FromStringAndSize(drec.dptr, drec.dsize);
+ v = PyByteArray_FromStringAndSize(drec.dptr, drec.dsize);
free(drec.dptr);
return v;
}
@@ -220,7 +220,7 @@
key = gdbm_firstkey(dp->di_dbm);
while (key.dptr) {
- item = PyBytes_FromStringAndSize(key.dptr, key.dsize);
+ item = PyByteArray_FromStringAndSize(key.dptr, key.dsize);
if (item == NULL) {
free(key.dptr);
Py_DECREF(v);
@@ -291,7 +291,7 @@
check_dbmobject_open(dp);
key = gdbm_firstkey(dp->di_dbm);
if (key.dptr) {
- v = PyBytes_FromStringAndSize(key.dptr, key.dsize);
+ v = PyByteArray_FromStringAndSize(key.dptr, key.dsize);
free(key.dptr);
return v;
}
@@ -323,7 +323,7 @@
check_dbmobject_open(dp);
nextkey = gdbm_nextkey(dp->di_dbm, key);
if (nextkey.dptr) {
- v = PyBytes_FromStringAndSize(nextkey.dptr, nextkey.dsize);
+ v = PyByteArray_FromStringAndSize(nextkey.dptr, nextkey.dsize);
free(nextkey.dptr);
return v;
}
Modified: python/branches/py3k-grandrenaming/Modules/mmapmodule.c
==============================================================================
--- python/branches/py3k-grandrenaming/Modules/mmapmodule.c (original)
+++ python/branches/py3k-grandrenaming/Modules/mmapmodule.c Tue Jan 1 20:14:44 2008
@@ -228,7 +228,7 @@
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 @@
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;
}
@@ -658,7 +658,7 @@
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 *
@@ -748,14 +748,14 @@
"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;
}
Modified: python/branches/py3k-grandrenaming/Modules/ossaudiodev.c
==============================================================================
--- python/branches/py3k-grandrenaming/Modules/ossaudiodev.c (original)
+++ python/branches/py3k-grandrenaming/Modules/ossaudiodev.c Tue Jan 1 20:14:44 2008
@@ -366,10 +366,10 @@
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 @@
return NULL;
}
self->icount += count;
- PyBytes_Resize(rv, count);
+ PyByteArray_Resize(rv, count);
return rv;
}
Modified: python/branches/py3k-grandrenaming/Modules/pyexpat.c
==============================================================================
--- python/branches/py3k-grandrenaming/Modules/pyexpat.c (original)
+++ python/branches/py3k-grandrenaming/Modules/pyexpat.c Tue Jan 1 20:14:44 2008
@@ -866,8 +866,8 @@
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)",
Modified: python/branches/py3k-grandrenaming/Modules/zipimport.c
==============================================================================
--- python/branches/py3k-grandrenaming/Modules/zipimport.c (original)
+++ python/branches/py3k-grandrenaming/Modules/zipimport.c Tue Jan 1 20:14:44 2008
@@ -467,7 +467,7 @@
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;
}
@@ -829,13 +829,13 @@
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)
@@ -855,7 +855,7 @@
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;
}
@@ -896,8 +896,8 @@
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,
@@ -942,16 +942,16 @@
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 "
@@ -971,7 +971,7 @@
}
*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;
}
@@ -987,7 +987,7 @@
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;
Modified: python/branches/py3k-grandrenaming/Modules/zlibmodule.c
==============================================================================
--- python/branches/py3k-grandrenaming/Modules/zlibmodule.c (original)
+++ python/branches/py3k-grandrenaming/Modules/zlibmodule.c Tue Jan 1 20:14:44 2008
@@ -96,12 +96,12 @@
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 @@
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 @@
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 @@
/* 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 @@
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 @@
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 @@
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 @@
/* 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 @@
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 @@
/* 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 @@
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 @@
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 @@
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 @@
*/
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 @@
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 @@
/* 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 @@
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 @@
/* 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 @@
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;
}
@@ -794,7 +794,7 @@
if (!PyArg_ParseTuple(args, "|i:flush", &length))
return NULL;
- if (!(retval = PyBytes_FromStringAndSize(NULL, length)))
+ if (!(retval = PyByteArray_FromStringAndSize(NULL, length)))
return NULL;
@@ -802,7 +802,7 @@
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);
@@ -811,12 +811,12 @@
/* 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;
@@ -838,7 +838,7 @@
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;
}
Modified: python/branches/py3k-grandrenaming/Objects/bytesobject.c
==============================================================================
--- python/branches/py3k-grandrenaming/Objects/bytesobject.c (original)
+++ python/branches/py3k-grandrenaming/Objects/bytesobject.c Tue Jan 1 20:14:44 2008
@@ -8,15 +8,15 @@
static PyBytesObject *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(PyBytesObject, &PyByteArray_Type);
if (nullbytes == NULL)
return 0;
nullbytes->ob_bytes = NULL;
@@ -96,21 +96,21 @@
/* 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;
Py_ssize_t alloc;
assert(size >= 0);
- new = PyObject_New(PyBytesObject, &PyBytes_Type);
+ new = PyObject_New(PyBytesObject, &PyByteArray_Type);
if (new == NULL)
return NULL;
@@ -137,31 +137,31 @@
}
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;
assert(self != NULL);
- assert(PyBytes_Check(self));
+ assert(PyByteArray_Check(self));
assert(size >= 0);
if (size < alloc / 2) {
@@ -208,7 +208,7 @@
}
PyObject *
-PyBytes_Concat(PyObject *a, PyObject *b)
+PyByteArray_Concat(PyObject *a, PyObject *b)
{
Py_ssize_t size;
Py_buffer va, vb;
@@ -229,7 +229,7 @@
goto done;
}
- result = (PyBytesObject *) PyBytes_FromStringAndSize(NULL, size);
+ result = (PyBytesObject *) 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);
@@ -274,7 +274,7 @@
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;
}
@@ -297,7 +297,7 @@
size = mysize * count;
if (count != 0 && size / count != mysize)
return PyErr_NoMemory();
- result = (PyBytesObject *)PyBytes_FromStringAndSize(NULL, size);
+ result = (PyBytesObject *)PyByteArray_FromStringAndSize(NULL, size);
if (result != NULL && size != 0) {
if (mysize == 1)
memset(result->ob_bytes, self->ob_bytes[0], size);
@@ -326,7 +326,7 @@
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)
@@ -363,7 +363,7 @@
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");
@@ -374,19 +374,19 @@
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;
@@ -397,7 +397,7 @@
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;
}
@@ -421,7 +421,7 @@
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 = bytearray_setslice(self, lo, hi, values);
@@ -467,7 +467,7 @@
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;
@@ -536,7 +536,7 @@
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");
@@ -565,7 +565,7 @@
}
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;
}
@@ -579,10 +579,10 @@
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 = bytearray_ass_subscript(self, item, values);
@@ -590,7 +590,7 @@
return err;
}
else {
- assert(PyBytes_Check(values));
+ assert(PyByteArray_Check(values));
bytes = ((PyBytesObject *)values)->ob_bytes;
needed = Py_SIZE(values);
}
@@ -610,7 +610,7 @@
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) {
@@ -644,21 +644,21 @@
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;
@@ -694,7 +694,7 @@
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;
}
@@ -750,7 +750,7 @@
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);
}
@@ -764,7 +764,7 @@
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);
@@ -814,7 +814,7 @@
/* 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;
}
@@ -860,7 +860,7 @@
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 */
@@ -1017,11 +1017,11 @@
#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"
@@ -1066,11 +1066,11 @@
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;
@@ -1105,7 +1105,7 @@
bytearray_count(PyBytesObject *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;
@@ -1117,7 +1117,7 @@
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)
@@ -1196,7 +1196,7 @@
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;
@@ -1206,7 +1206,7 @@
return -1;
}
- return memchr(PyBytes_AS_STRING(self), ival, Py_SIZE(self)) != NULL;
+ return memchr(PyByteArray_AS_STRING(self), ival, Py_SIZE(self)) != NULL;
}
@@ -1218,12 +1218,12 @@
_bytes_tailmatch(PyBytesObject *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;
@@ -1382,12 +1382,12 @@
}
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 */
@@ -1396,7 +1396,7 @@
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);
@@ -1417,7 +1417,7 @@
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;
@@ -1425,7 +1425,7 @@
}
/* 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);
@@ -1455,13 +1455,13 @@
Py_LOCAL(PyBytesObject *)
return_self(PyBytesObject *self)
{
- if (PyBytes_CheckExact(self)) {
+ if (PyByteArray_CheckExact(self)) {
Py_INCREF(self);
return (PyBytesObject *)self;
}
- return (PyBytesObject *)PyBytes_FromStringAndSize(
- PyBytes_AS_STRING(self),
- PyBytes_GET_SIZE(self));
+ return (PyBytesObject *)PyByteArray_FromStringAndSize(
+ PyByteArray_AS_STRING(self),
+ PyByteArray_GET_SIZE(self));
}
Py_LOCAL_INLINE(Py_ssize_t)
@@ -1581,7 +1581,7 @@
Py_ssize_t count, i, product;
PyBytesObject *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;
@@ -1604,11 +1604,11 @@
}
if (! (result = (PyBytesObject *)
- PyBytes_FromStringAndSize(NULL, result_len)) )
+ 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 */
@@ -1641,8 +1641,8 @@
Py_ssize_t count;
PyBytesObject *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) {
@@ -1653,9 +1653,9 @@
assert(result_len>=0);
if ( (result = (PyBytesObject *)
- PyBytes_FromStringAndSize(NULL, result_len)) == NULL)
+ 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;
@@ -1685,8 +1685,8 @@
Py_ssize_t count, offset;
PyBytesObject *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,
@@ -1702,10 +1702,10 @@
assert (result_len>=0);
if ( (result = (PyBytesObject *)
- PyBytes_FromStringAndSize(NULL, result_len)) == NULL )
+ 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;
@@ -1737,8 +1737,8 @@
PyBytesObject *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);
@@ -1748,10 +1748,10 @@
}
/* Need to make a new bytes */
- result = (PyBytesObject *) PyBytes_FromStringAndSize(NULL, self_len);
+ result = (PyBytesObject *) 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 */
@@ -1785,8 +1785,8 @@
/* 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,
@@ -1797,10 +1797,10 @@
}
/* Need to make a new bytes */
- result = (PyBytesObject *) PyBytes_FromStringAndSize(NULL, self_len);
+ result = (PyBytesObject *) 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 */
@@ -1835,8 +1835,8 @@
Py_ssize_t count, product;
PyBytesObject *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) {
@@ -1858,9 +1858,9 @@
}
if ( (result = (PyBytesObject *)
- PyBytes_FromStringAndSize(NULL, result_len)) == NULL)
+ 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;
@@ -1902,8 +1902,8 @@
Py_ssize_t count, offset, product;
PyBytesObject *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,
@@ -1927,9 +1927,9 @@
}
if ( (result = (PyBytesObject *)
- PyBytes_FromStringAndSize(NULL, result_len)) == NULL)
+ 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;
@@ -1969,7 +1969,7 @@
{
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);
}
@@ -1992,7 +1992,7 @@
/* 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);
}
@@ -2080,7 +2080,7 @@
(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; \
@@ -2092,7 +2092,7 @@
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; \
@@ -2193,9 +2193,9 @@
static PyObject *
bytearray_split(PyBytesObject *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
@@ -2273,7 +2273,7 @@
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,15 +2299,15 @@
{
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,15 +2327,15 @@
{
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);
@@ -2428,9 +2428,9 @@
static PyObject *
bytearray_rsplit(PyBytesObject *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;
@@ -2532,7 +2532,7 @@
"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) {
@@ -2565,7 +2565,7 @@
"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;
@@ -2625,7 +2625,7 @@
Py_DECREF(it);
/* XXX: Is possible to avoid a full copy of the buffer? */
- tmp = PyBytes_FromStringAndSize(buf, len);
+ tmp = PyByteArray_FromStringAndSize(buf, len);
res = bytearray_extend(self, tmp);
Py_DECREF(tmp);
PyMem_Free(buf);
@@ -2661,7 +2661,7 @@
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);
@@ -2690,7 +2690,7 @@
}
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;
@@ -2751,7 +2751,7 @@
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__,
@@ -2784,7 +2784,7 @@
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__,
@@ -2817,7 +2817,7 @@
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,
@@ -2881,7 +2881,7 @@
/* 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')",
@@ -2899,16 +2899,16 @@
}
/* 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) {
@@ -2967,10 +2967,10 @@
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] == ' ')
@@ -2987,7 +2987,7 @@
}
buf[j++] = (top << 4) + bot;
}
- if (PyBytes_Resize(newbytes, j) < 0)
+ if (PyByteArray_Resize(newbytes, j) < 0)
goto error;
return newbytes;
@@ -3020,7 +3020,7 @@
static PySequenceMethods bytearray_as_sequence = {
(lenfunc)bytearray_length, /* sq_length */
- (binaryfunc)PyBytes_Concat, /* sq_concat */
+ (binaryfunc)PyByteArray_Concat, /* sq_concat */
(ssizeargfunc)bytearray_repeat, /* sq_repeat */
(ssizeargfunc)bytearray_getitem, /* sq_item */
0, /* sq_slice */
@@ -3125,7 +3125,7 @@
static PyObject *bytearray_iter(PyObject *seq);
-PyTypeObject PyBytes_Type = {
+PyTypeObject PyByteArray_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"bytearray",
sizeof(PyBytesObject),
@@ -3200,9 +3200,9 @@
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)
@@ -3220,7 +3220,7 @@
{
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);
}
@@ -3271,7 +3271,7 @@
{
bytesiterobject *it;
- if (!PyBytes_Check(seq)) {
+ if (!PyByteArray_Check(seq)) {
PyErr_BadInternalCall();
return NULL;
}
Modified: python/branches/py3k-grandrenaming/Objects/longobject.c
==============================================================================
--- python/branches/py3k-grandrenaming/Objects/longobject.c (original)
+++ python/branches/py3k-grandrenaming/Objects/longobject.c Tue Jan 1 20:14:44 2008
@@ -3461,13 +3461,13 @@
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) {
Modified: python/branches/py3k-grandrenaming/Objects/memoryobject.c
==============================================================================
--- python/branches/py3k-grandrenaming/Objects/memoryobject.c (original)
+++ python/branches/py3k-grandrenaming/Objects/memoryobject.c Tue Jan 1 20:14:44 2008
@@ -254,12 +254,12 @@
"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 PyObject *
memory_tobytes(PyMemoryViewObject *mem, PyObject *noargs)
{
- return PyBytes_FromObject((PyObject *)mem);
+ return PyByteArray_FromObject((PyObject *)mem);
}
static PyObject *
@@ -451,8 +451,8 @@
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 @@
{
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 */
Modified: python/branches/py3k-grandrenaming/Objects/object.c
==============================================================================
--- python/branches/py3k-grandrenaming/Objects/object.c (original)
+++ python/branches/py3k-grandrenaming/Objects/object.c Tue Jan 1 20:14:44 2008
@@ -1486,7 +1486,7 @@
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)
Modified: python/branches/py3k-grandrenaming/Objects/stringobject.c
==============================================================================
--- python/branches/py3k-grandrenaming/Objects/stringobject.c (original)
+++ python/branches/py3k-grandrenaming/Objects/stringobject.c Tue Jan 1 20:14:44 2008
@@ -1470,7 +1470,7 @@
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",
@@ -1512,7 +1512,7 @@
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;
}
Modified: python/branches/py3k-grandrenaming/Objects/unicodeobject.c
==============================================================================
--- python/branches/py3k-grandrenaming/Objects/unicodeobject.c (original)
+++ python/branches/py3k-grandrenaming/Objects/unicodeobject.c Tue Jan 1 20:14:44 2008
@@ -1688,11 +1688,11 @@
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];
@@ -1758,7 +1758,7 @@
*out++ = '-';
}
- result = PyString_FromStringAndSize(PyBytes_AS_STRING(v), out - start);
+ result = PyString_FromStringAndSize(PyByteArray_AS_STRING(v), out - start);
Py_DECREF(v);
return result;
}
@@ -2309,12 +2309,12 @@
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)
@@ -2351,7 +2351,7 @@
}
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
@@ -2578,12 +2578,12 @@
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)
@@ -2615,7 +2615,7 @@
}
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
@@ -2928,7 +2928,7 @@
escape.
*/
- repr = PyBytes_FromStringAndSize(NULL,
+ repr = PyByteArray_FromStringAndSize(NULL,
#ifdef Py_UNICODE_WIDE
+ 10*size
#else
@@ -2938,7 +2938,7 @@
if (repr == NULL)
return NULL;
- p = PyBytes_AS_STRING(repr);
+ p = PyByteArray_AS_STRING(repr);
while (size-- > 0) {
Py_UNICODE ch = *s++;
@@ -3030,8 +3030,8 @@
*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;
}
@@ -3048,8 +3048,8 @@
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;
}
@@ -3169,16 +3169,16 @@
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
@@ -3213,7 +3213,7 @@
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;
}
@@ -3230,8 +3230,8 @@
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;
}
@@ -3464,10 +3464,10 @@
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) {
@@ -3517,7 +3517,7 @@
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)
@@ -3544,9 +3544,9 @@
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) */
@@ -3564,17 +3564,17 @@
/* 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
@@ -3594,8 +3594,8 @@
}
}
}
- 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);
Modified: python/branches/py3k-grandrenaming/PC/_winreg.c
==============================================================================
--- python/branches/py3k-grandrenaming/PC/_winreg.c (original)
+++ python/branches/py3k-grandrenaming/PC/_winreg.c Tue Jan 1 20:14:44 2008
@@ -870,7 +870,7 @@
obData = Py_None;
}
else
- obData = PyBytes_FromStringAndSize(
+ obData = PyByteArray_FromStringAndSize(
(char *)retDataBuf, retDataSize);
break;
}
Modified: python/branches/py3k-grandrenaming/Parser/tokenizer.c
==============================================================================
--- python/branches/py3k-grandrenaming/Parser/tokenizer.c (original)
+++ python/branches/py3k-grandrenaming/Parser/tokenizer.c Tue Jan 1 20:14:44 2008
@@ -406,17 +406,17 @@
}
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;
Modified: python/branches/py3k-grandrenaming/Python/bltinmodule.c
==============================================================================
--- python/branches/py3k-grandrenaming/Python/bltinmodule.c (original)
+++ python/branches/py3k-grandrenaming/Python/bltinmodule.c Tue Jan 1 20:14:44 2008
@@ -1148,11 +1148,11 @@
}
#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);
}
}
@@ -1628,7 +1628,7 @@
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);
@@ -1911,7 +1911,7 @@
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
Modified: python/branches/py3k-grandrenaming/Python/codecs.c
==============================================================================
--- python/branches/py3k-grandrenaming/Python/codecs.c (original)
+++ python/branches/py3k-grandrenaming/Python/codecs.c Tue Jan 1 20:14:44 2008
@@ -345,7 +345,7 @@
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 @@
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);
Modified: python/branches/py3k-grandrenaming/Python/getargs.c
==============================================================================
--- python/branches/py3k-grandrenaming/Python/getargs.c (original)
+++ python/branches/py3k-grandrenaming/Python/getargs.c Tue Jan 1 20:14:44 2008
@@ -968,7 +968,7 @@
/* 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)
@@ -1122,7 +1122,7 @@
case 'Y': { /* PyBytes 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);
Modified: python/branches/py3k-grandrenaming/Python/import.c
==============================================================================
--- python/branches/py3k-grandrenaming/Python/import.c (original)
+++ python/branches/py3k-grandrenaming/Python/import.c Tue Jan 1 20:14:44 2008
@@ -2599,7 +2599,7 @@
buf[2] = (char) ((pyc_magic >> 16) & 0xff);
buf[3] = (char) ((pyc_magic >> 24) & 0xff);
- return PyBytes_FromStringAndSize(buf, 4);
+ return PyByteArray_FromStringAndSize(buf, 4);
}
static PyObject *
Modified: python/branches/py3k-grandrenaming/Python/mactoolboxglue.c
==============================================================================
--- python/branches/py3k-grandrenaming/Python/mactoolboxglue.c (original)
+++ python/branches/py3k-grandrenaming/Python/mactoolboxglue.c Tue Jan 1 20:14:44 2008
@@ -170,9 +170,9 @@
str = PyString_AS_STRING(v);
len = PyString_GET_SIZE(v);
}
- else if (PyBytes_Check(v)) {
- str = PyBytes_AS_STRING(v);
- len = PyBytes_GET_SIZE(v);
+ else if (PyByteArray_Check(v)) {
+ str = PyByteArray_AS_STRING(v);
+ len = PyByteArray_GET_SIZE(v);
}
else {
PyErr_SetString(PyExc_TypeError,
@@ -221,9 +221,9 @@
ptr = PyString_AS_STRING(v);
len = PyString_GET_SIZE(v);
}
- else if (PyBytes_Check(v)) {
- ptr = PyBytes_AS_STRING(v);
- len = PyBytes_GET_SIZE(v);
+ else if (PyByteArray_Check(v)) {
+ ptr = PyByteArray_AS_STRING(v);
+ len = PyByteArray_GET_SIZE(v);
}
if (len > 255) {
PyErr_SetString(PyExc_TypeError,
Modified: python/branches/py3k-grandrenaming/Python/marshal.c
==============================================================================
--- python/branches/py3k-grandrenaming/Python/marshal.c (original)
+++ python/branches/py3k-grandrenaming/Python/marshal.c Tue Jan 1 20:14:44 2008
@@ -1095,7 +1095,7 @@
}
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 @@
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,
Modified: python/branches/py3k-grandrenaming/Python/pythonrun.c
==============================================================================
--- python/branches/py3k-grandrenaming/Python/pythonrun.c (original)
+++ python/branches/py3k-grandrenaming/Python/pythonrun.c Tue Jan 1 20:14:44 2008
@@ -194,7 +194,7 @@
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();
@@ -495,7 +495,7 @@
PyList_Fini();
PySet_Fini();
PyString_Fini();
- PyBytes_Fini();
+ PyByteArray_Fini();
PyLong_Fini();
PyFloat_Fini();
More information about the Python-3000-checkins
mailing list