Skip to content

Commit 9c4756e

Browse files
committed
Renamed PyBytes to PyByteArray
1 parent 96d02f3 commit 9c4756e

31 files changed

+397
-397
lines changed

Include/bytes_methods.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define Py_BYTES_CTYPE_H
33

44
/*
5-
* The internal implementation behind PyString (bytes) and PyBytes (buffer)
5+
* The internal implementation behind PyBytes (bytes) and PyByteArray (bytearray)
66
* methods of the given names, they operate on ASCII byte strings.
77
*/
88
extern PyObject* _Py_bytes_isspace(const char *cptr, Py_ssize_t len);

Include/bytesobject.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ extern "C" {
88

99
#include <stdarg.h>
1010

11-
/* Type PyBytesObject represents a mutable array of bytes.
11+
/* Type PyByteArrayObject represents a mutable array of bytes.
1212
* The Python API is that of a sequence;
1313
* the bytes are mapped to ints in [0, 256).
1414
* Bytes are not characters; they may be used to encode characters.
@@ -25,27 +25,27 @@ typedef struct {
2525
int ob_exports; /* how many buffer exports */
2626
Py_ssize_t ob_alloc; /* How many bytes allocated */
2727
char *ob_bytes;
28-
} PyBytesObject;
28+
} PyByteArrayObject;
2929

3030
/* Type object */
31-
PyAPI_DATA(PyTypeObject) PyBytes_Type;
32-
PyAPI_DATA(PyTypeObject) PyBytesIter_Type;
31+
PyAPI_DATA(PyTypeObject) PyByteArray_Type;
32+
PyAPI_DATA(PyTypeObject) PyByteArrayIter_Type;
3333

3434
/* Type check macros */
35-
#define PyBytes_Check(self) PyObject_TypeCheck(self, &PyBytes_Type)
36-
#define PyBytes_CheckExact(self) (Py_TYPE(self) == &PyBytes_Type)
35+
#define PyByteArray_Check(self) PyObject_TypeCheck(self, &PyByteArray_Type)
36+
#define PyByteArray_CheckExact(self) (Py_TYPE(self) == &PyByteArray_Type)
3737

3838
/* Direct API functions */
39-
PyAPI_FUNC(PyObject *) PyBytes_FromObject(PyObject *);
40-
PyAPI_FUNC(PyObject *) PyBytes_Concat(PyObject *, PyObject *);
41-
PyAPI_FUNC(PyObject *) PyBytes_FromStringAndSize(const char *, Py_ssize_t);
42-
PyAPI_FUNC(Py_ssize_t) PyBytes_Size(PyObject *);
43-
PyAPI_FUNC(char *) PyBytes_AsString(PyObject *);
44-
PyAPI_FUNC(int) PyBytes_Resize(PyObject *, Py_ssize_t);
39+
PyAPI_FUNC(PyObject *) PyByteArray_FromObject(PyObject *);
40+
PyAPI_FUNC(PyObject *) PyByteArray_Concat(PyObject *, PyObject *);
41+
PyAPI_FUNC(PyObject *) PyByteArray_FromStringAndSize(const char *, Py_ssize_t);
42+
PyAPI_FUNC(Py_ssize_t) PyByteArray_Size(PyObject *);
43+
PyAPI_FUNC(char *) PyByteArray_AsString(PyObject *);
44+
PyAPI_FUNC(int) PyByteArray_Resize(PyObject *, Py_ssize_t);
4545

4646
/* Macros, trading safety for speed */
47-
#define PyBytes_AS_STRING(self) (assert(PyBytes_Check(self)),((PyBytesObject *)(self))->ob_bytes)
48-
#define PyBytes_GET_SIZE(self) (assert(PyBytes_Check(self)),Py_SIZE(self))
47+
#define PyByteArray_AS_STRING(self) (assert(PyByteArray_Check(self)),((PyByteArrayObject *)(self))->ob_bytes)
48+
#define PyByteArray_GET_SIZE(self) (assert(PyByteArray_Check(self)),Py_SIZE(self))
4949

5050
#ifdef __cplusplus
5151
}

Include/pythonrun.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ PyAPI_FUNC(void) _PyExc_Init(void);
126126
PyAPI_FUNC(void) _PyImportHooks_Init(void);
127127
PyAPI_FUNC(int) _PyFrame_Init(void);
128128
PyAPI_FUNC(void) _PyFloat_Init(void);
129-
PyAPI_FUNC(int) PyBytes_Init(void);
129+
PyAPI_FUNC(int) PyByteArray_Init(void);
130130

131131
/* Various internal finalizers */
132132
PyAPI_FUNC(void) _PyExc_Fini(void);
@@ -139,7 +139,7 @@ PyAPI_FUNC(void) PyTuple_Fini(void);
139139
PyAPI_FUNC(void) PyList_Fini(void);
140140
PyAPI_FUNC(void) PySet_Fini(void);
141141
PyAPI_FUNC(void) PyString_Fini(void);
142-
PyAPI_FUNC(void) PyBytes_Fini(void);
142+
PyAPI_FUNC(void) PyByteArray_Fini(void);
143143
PyAPI_FUNC(void) PyFloat_Fini(void);
144144
PyAPI_FUNC(void) PyOS_FiniInterrupts(void);
145145

Modules/_bsddb.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,14 +1174,14 @@ _db_associateCallback(DB* db, const DBT* priKey, const DBT* priData,
11741174
else if (PyLong_Check(result)) {
11751175
retval = PyLong_AsLong(result);
11761176
}
1177-
else if (PyBytes_Check(result) || PyString_Check(result)) {
1177+
else if (PyByteArray_Check(result) || PyString_Check(result)) {
11781178
char* data;
11791179
Py_ssize_t size;
11801180

11811181
CLEAR_DBT(*secKey);
11821182
size = Py_SIZE(result);
1183-
if (PyBytes_Check(result))
1184-
data = PyBytes_AS_STRING(result);
1183+
if (PyByteArray_Check(result))
1184+
data = PyByteArray_AS_STRING(result);
11851185
else
11861186
data = PyString_AS_STRING(result);
11871187
secKey->flags = DB_DBT_APPMALLOC; /* DB will free */

Modules/_ctypes/_ctypes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1596,7 +1596,7 @@ c_void_p_from_param(PyObject *type, PyObject *value)
15961596
return (PyObject *)parg;
15971597
}
15981598
/* bytes */
1599-
if (PyBytes_Check(value)) {
1599+
if (PyByteArray_Check(value)) {
16001600
PyCArgObject *parg;
16011601
struct fielddesc *fd = getentry("z");
16021602

Modules/_ctypes/cfield.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,8 +1172,8 @@ c_set(void *ptr, PyObject *value, Py_ssize_t size)
11721172
*(char *)ptr = PyString_AS_STRING(value)[0];
11731173
_RET(value);
11741174
}
1175-
if (PyBytes_Check(value) && PyBytes_GET_SIZE(value) == 1) {
1176-
*(char *)ptr = PyBytes_AS_STRING(value)[0];
1175+
if (PyByteArray_Check(value) && PyByteArray_GET_SIZE(value) == 1) {
1176+
*(char *)ptr = PyByteArray_AS_STRING(value)[0];
11771177
_RET(value);
11781178
}
11791179
if (PyLong_Check(value))

Modules/_dbmmodule.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ dbm_subscript(dbmobject *dp, register PyObject *key)
111111
PyErr_SetString(DbmError, "");
112112
return NULL;
113113
}
114-
return PyBytes_FromStringAndSize(drec.dptr, drec.dsize);
114+
return PyByteArray_FromStringAndSize(drec.dptr, drec.dsize);
115115
}
116116

117117
static int
@@ -188,7 +188,7 @@ dbm_keys(register dbmobject *dp, PyObject *unused)
188188
return NULL;
189189
for (key = dbm_firstkey(dp->di_dbm); key.dptr;
190190
key = dbm_nextkey(dp->di_dbm)) {
191-
item = PyBytes_FromStringAndSize(key.dptr, key.dsize);
191+
item = PyByteArray_FromStringAndSize(key.dptr, key.dsize);
192192
if (item == NULL) {
193193
Py_DECREF(v);
194194
return NULL;
@@ -260,7 +260,7 @@ dbm_get(register dbmobject *dp, PyObject *args)
260260
check_dbmobject_open(dp);
261261
val = dbm_fetch(dp->di_dbm, key);
262262
if (val.dptr != NULL)
263-
return PyBytes_FromStringAndSize(val.dptr, val.dsize);
263+
return PyByteArray_FromStringAndSize(val.dptr, val.dsize);
264264
else {
265265
Py_INCREF(defvalue);
266266
return defvalue;
@@ -283,9 +283,9 @@ dbm_setdefault(register dbmobject *dp, PyObject *args)
283283
check_dbmobject_open(dp);
284284
val = dbm_fetch(dp->di_dbm, key);
285285
if (val.dptr != NULL)
286-
return PyBytes_FromStringAndSize(val.dptr, val.dsize);
286+
return PyByteArray_FromStringAndSize(val.dptr, val.dsize);
287287
if (defvalue == NULL) {
288-
defvalue = PyBytes_FromStringAndSize(NULL, 0);
288+
defvalue = PyByteArray_FromStringAndSize(NULL, 0);
289289
if (defvalue == NULL)
290290
return NULL;
291291
val.dptr = NULL;

Modules/_sqlite/cursor.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ PyObject* _pysqlite_fetch_one_row(pysqlite_Cursor* self)
352352
}
353353
PyOS_snprintf(buf, sizeof(buf) - 1, "Could not decode to UTF-8 column '%s' with text '%s'",
354354
colname , val_str);
355-
buf_bytes = PyBytes_FromStringAndSize(buf, strlen(buf));
355+
buf_bytes = PyByteArray_FromStringAndSize(buf, strlen(buf));
356356
if (!buf_bytes) {
357357
PyErr_SetString(pysqlite_OperationalError, "Could not decode to UTF-8");
358358
} else {
@@ -368,8 +368,8 @@ PyObject* _pysqlite_fetch_one_row(pysqlite_Cursor* self)
368368
}
369369
} else if (self->connection->text_factory == (PyObject*)&PyString_Type) {
370370
converted = PyString_FromString(val_str);
371-
} else if (self->connection->text_factory == (PyObject*)&PyBytes_Type) {
372-
converted = PyBytes_FromStringAndSize(val_str, strlen(val_str));
371+
} else if (self->connection->text_factory == (PyObject*)&PyByteArray_Type) {
372+
converted = PyByteArray_FromStringAndSize(val_str, strlen(val_str));
373373
} else {
374374
converted = PyObject_CallFunction(self->connection->text_factory, "y", val_str);
375375
}

Modules/_sqlite/module.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ static PyObject* module_register_adapter(PyObject* self, PyObject* args, PyObjec
137137
/* a basic type is adapted; there's a performance optimization if that's not the case
138138
* (99 % of all usages) */
139139
if (type == &PyLong_Type || type == &PyFloat_Type
140-
|| type == &PyUnicode_Type || type == &PyBytes_Type) {
140+
|| type == &PyUnicode_Type || type == &PyByteArray_Type) {
141141
pysqlite_BaseTypeAdapted = 1;
142142
}
143143

Modules/_sqlite/statement.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ static int _need_adapt(PyObject* obj)
167167
}
168168

169169
if (PyLong_CheckExact(obj) || PyFloat_CheckExact(obj)
170-
|| PyUnicode_CheckExact(obj) || PyBytes_CheckExact(obj)) {
170+
|| PyUnicode_CheckExact(obj) || PyByteArray_CheckExact(obj)) {
171171
return 0;
172172
} else {
173173
return 1;

0 commit comments

Comments
 (0)