| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,7 +2,7 @@ | |||
| 2 | 2 | #define Py_BYTES_CTYPE_H | |
| 3 | 3 | ||
| 4 | 4 | /* | |
| 5 | - * The internal implementation behind PyString (bytes) and PyBytes (buffer) | ||
| 5 | + * The internal implementation behind PyBytes (bytes) and PyByteArray (bytearray) | ||
| 6 | 6 | * methods of the given names, they operate on ASCII byte strings. | |
| 7 | 7 | */ | |
| 8 | 8 | extern PyObject* _Py_bytes_isspace(const char *cptr, Py_ssize_t len); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,7 +8,7 @@ extern "C" { | |||
| 8 | 8 | ||
| 9 | 9 | #include <stdarg.h> | |
| 10 | 10 | ||
| 11 | - /* Type PyBytesObject represents a mutable array of bytes. | ||
| 11 | + /* Type PyByteArrayObject represents a mutable array of bytes. | ||
| 12 | 12 | * The Python API is that of a sequence; | |
| 13 | 13 | * the bytes are mapped to ints in [0, 256). | |
| 14 | 14 | * Bytes are not characters; they may be used to encode characters. | |
@@ -25,27 +25,27 @@ typedef struct { | |||
| 25 | 25 | int ob_exports; /* how many buffer exports */ | |
| 26 | 26 | Py_ssize_t ob_alloc; /* How many bytes allocated */ | |
| 27 | 27 | char *ob_bytes; | |
| 28 | - } PyBytesObject; | ||
| 28 | + } PyByteArrayObject; | ||
| 29 | 29 | ||
| 30 | 30 | /* 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; | ||
| 33 | 33 | ||
| 34 | 34 | /* 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) | ||
| 37 | 37 | ||
| 38 | 38 | /* 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); | ||
| 45 | 45 | ||
| 46 | 46 | /* 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)) | ||
| 49 | 49 | ||
| 50 | 50 | #ifdef __cplusplus | |
| 51 | 51 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -126,7 +126,7 @@ PyAPI_FUNC(void) _PyExc_Init(void); | |||
| 126 | 126 | PyAPI_FUNC(void) _PyImportHooks_Init(void); | |
| 127 | 127 | PyAPI_FUNC(int) _PyFrame_Init(void); | |
| 128 | 128 | PyAPI_FUNC(void) _PyFloat_Init(void); | |
| 129 | - PyAPI_FUNC(int) PyBytes_Init(void); | ||
| 129 | + PyAPI_FUNC(int) PyByteArray_Init(void); | ||
| 130 | 130 | ||
| 131 | 131 | /* Various internal finalizers */ | |
| 132 | 132 | PyAPI_FUNC(void) _PyExc_Fini(void); | |
@@ -139,7 +139,7 @@ PyAPI_FUNC(void) PyTuple_Fini(void); | |||
| 139 | 139 | PyAPI_FUNC(void) PyList_Fini(void); | |
| 140 | 140 | PyAPI_FUNC(void) PySet_Fini(void); | |
| 141 | 141 | PyAPI_FUNC(void) PyString_Fini(void); | |
| 142 | - PyAPI_FUNC(void) PyBytes_Fini(void); | ||
| 142 | + PyAPI_FUNC(void) PyByteArray_Fini(void); | ||
| 143 | 143 | PyAPI_FUNC(void) PyFloat_Fini(void); | |
| 144 | 144 | PyAPI_FUNC(void) PyOS_FiniInterrupts(void); | |
| 145 | 145 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1174,14 +1174,14 @@ _db_associateCallback(DB* db, const DBT* priKey, const DBT* priData, | |||
| 1174 | 1174 | else if (PyLong_Check(result)) { | |
| 1175 | 1175 | retval = PyLong_AsLong(result); | |
| 1176 | 1176 | } | |
| 1177 | - else if (PyBytes_Check(result) || PyString_Check(result)) { | ||
| 1177 | + else if (PyByteArray_Check(result) || PyString_Check(result)) { | ||
| 1178 | 1178 | char* data; | |
| 1179 | 1179 | Py_ssize_t size; | |
| 1180 | 1180 | ||
| 1181 | 1181 | CLEAR_DBT(*secKey); | |
| 1182 | 1182 | 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); | ||
| 1185 | 1185 | else | |
| 1186 | 1186 | data = PyString_AS_STRING(result); | |
| 1187 | 1187 | secKey->flags = DB_DBT_APPMALLOC; /* DB will free */ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1596,7 +1596,7 @@ c_void_p_from_param(PyObject *type, PyObject *value) | |||
| 1596 | 1596 | return (PyObject *)parg; | |
| 1597 | 1597 | } | |
| 1598 | 1598 | /* bytes */ | |
| 1599 | - if (PyBytes_Check(value)) { | ||
| 1599 | + if (PyByteArray_Check(value)) { | ||
| 1600 | 1600 | PyCArgObject *parg; | |
| 1601 | 1601 | struct fielddesc *fd = getentry("z"); | |
| 1602 | 1602 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1172,8 +1172,8 @@ c_set(void *ptr, PyObject *value, Py_ssize_t size) | |||
| 1172 | 1172 | *(char *)ptr = PyString_AS_STRING(value)[0]; | |
| 1173 | 1173 | _RET(value); | |
| 1174 | 1174 | } | |
| 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]; | ||
| 1177 | 1177 | _RET(value); | |
| 1178 | 1178 | } | |
| 1179 | 1179 | if (PyLong_Check(value)) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -111,7 +111,7 @@ dbm_subscript(dbmobject *dp, register PyObject *key) | |||
| 111 | 111 | PyErr_SetString(DbmError, ""); | |
| 112 | 112 | return NULL; | |
| 113 | 113 | } | |
| 114 | - return PyBytes_FromStringAndSize(drec.dptr, drec.dsize); | ||
| 114 | + return PyByteArray_FromStringAndSize(drec.dptr, drec.dsize); | ||
| 115 | 115 | } | |
| 116 | 116 | ||
| 117 | 117 | static int | |
@@ -188,7 +188,7 @@ dbm_keys(register dbmobject *dp, PyObject *unused) | |||
| 188 | 188 | return NULL; | |
| 189 | 189 | for (key = dbm_firstkey(dp->di_dbm); key.dptr; | |
| 190 | 190 | key = dbm_nextkey(dp->di_dbm)) { | |
| 191 | - item = PyBytes_FromStringAndSize(key.dptr, key.dsize); | ||
| 191 | + item = PyByteArray_FromStringAndSize(key.dptr, key.dsize); | ||
| 192 | 192 | if (item == NULL) { | |
| 193 | 193 | Py_DECREF(v); | |
| 194 | 194 | return NULL; | |
@@ -260,7 +260,7 @@ dbm_get(register dbmobject *dp, PyObject *args) | |||
| 260 | 260 | check_dbmobject_open(dp); | |
| 261 | 261 | val = dbm_fetch(dp->di_dbm, key); | |
| 262 | 262 | if (val.dptr != NULL) | |
| 263 | - return PyBytes_FromStringAndSize(val.dptr, val.dsize); | ||
| 263 | + return PyByteArray_FromStringAndSize(val.dptr, val.dsize); | ||
| 264 | 264 | else { | |
| 265 | 265 | Py_INCREF(defvalue); | |
| 266 | 266 | return defvalue; | |
@@ -283,9 +283,9 @@ dbm_setdefault(register dbmobject *dp, PyObject *args) | |||
| 283 | 283 | check_dbmobject_open(dp); | |
| 284 | 284 | val = dbm_fetch(dp->di_dbm, key); | |
| 285 | 285 | if (val.dptr != NULL) | |
| 286 | - return PyBytes_FromStringAndSize(val.dptr, val.dsize); | ||
| 286 | + return PyByteArray_FromStringAndSize(val.dptr, val.dsize); | ||
| 287 | 287 | if (defvalue == NULL) { | |
| 288 | - defvalue = PyBytes_FromStringAndSize(NULL, 0); | ||
| 288 | + defvalue = PyByteArray_FromStringAndSize(NULL, 0); | ||
| 289 | 289 | if (defvalue == NULL) | |
| 290 | 290 | return NULL; | |
| 291 | 291 | val.dptr = NULL; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -352,7 +352,7 @@ PyObject* _pysqlite_fetch_one_row(pysqlite_Cursor* self) | |||
| 352 | 352 | } | |
| 353 | 353 | PyOS_snprintf(buf, sizeof(buf) - 1, "Could not decode to UTF-8 column '%s' with text '%s'", | |
| 354 | 354 | colname , val_str); | |
| 355 | - buf_bytes = PyBytes_FromStringAndSize(buf, strlen(buf)); | ||
| 355 | + buf_bytes = PyByteArray_FromStringAndSize(buf, strlen(buf)); | ||
| 356 | 356 | if (!buf_bytes) { | |
| 357 | 357 | PyErr_SetString(pysqlite_OperationalError, "Could not decode to UTF-8"); | |
| 358 | 358 | } else { | |
@@ -368,8 +368,8 @@ PyObject* _pysqlite_fetch_one_row(pysqlite_Cursor* self) | |||
| 368 | 368 | } | |
| 369 | 369 | } else if (self->connection->text_factory == (PyObject*)&PyString_Type) { | |
| 370 | 370 | 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)); | ||
| 373 | 373 | } else { | |
| 374 | 374 | converted = PyObject_CallFunction(self->connection->text_factory, "y", val_str); | |
| 375 | 375 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -137,7 +137,7 @@ static PyObject* module_register_adapter(PyObject* self, PyObject* args, PyObjec | |||
| 137 | 137 | /* a basic type is adapted; there's a performance optimization if that's not the case | |
| 138 | 138 | * (99 % of all usages) */ | |
| 139 | 139 | if (type == &PyLong_Type || type == &PyFloat_Type | |
| 140 | - || type == &PyUnicode_Type || type == &PyBytes_Type) { | ||
| 140 | + || type == &PyUnicode_Type || type == &PyByteArray_Type) { | ||
| 141 | 141 | pysqlite_BaseTypeAdapted = 1; | |
| 142 | 142 | } | |
| 143 | 143 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -167,7 +167,7 @@ static int _need_adapt(PyObject* obj) | |||
| 167 | 167 | } | |
| 168 | 168 | ||
| 169 | 169 | if (PyLong_CheckExact(obj) || PyFloat_CheckExact(obj) | |
| 170 | - || PyUnicode_CheckExact(obj) || PyBytes_CheckExact(obj)) { | ||
| 170 | + || PyUnicode_CheckExact(obj) || PyByteArray_CheckExact(obj)) { | ||
| 171 | 171 | return 0; | |
| 172 | 172 | } else { | |
| 173 | 173 | return 1; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments