diff options
author | Christian Heimes <christian@cheimes.de> | 2008-05-26 12:51:38 (GMT) |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2008-05-26 12:51:38 (GMT) |
commit | 593daf545bd9b7e7bcb27b498ecc6f36db9ae395 (patch) | |
tree | c0a57029b9ab0eb18a2bb4f8fd65f0817f1a1707 /Modules/_sqlite | |
parent | c3cb683d638e9d660c18a05293a576f98965166e (diff) | |
download | cpython-593daf545bd9b7e7bcb27b498ecc6f36db9ae395.zip cpython-593daf545bd9b7e7bcb27b498ecc6f36db9ae395.tar.gz cpython-593daf545bd9b7e7bcb27b498ecc6f36db9ae395.tar.bz2 |
Renamed PyString to PyBytes
Diffstat (limited to 'Modules/_sqlite')
-rw-r--r-- | Modules/_sqlite/cache.c | 4 | ||||
-rw-r--r-- | Modules/_sqlite/connection.c | 34 | ||||
-rw-r--r-- | Modules/_sqlite/connection.h | 2 | ||||
-rw-r--r-- | Modules/_sqlite/cursor.c | 30 | ||||
-rw-r--r-- | Modules/_sqlite/module.c | 6 | ||||
-rw-r--r-- | Modules/_sqlite/row.c | 6 | ||||
-rw-r--r-- | Modules/_sqlite/statement.c | 18 |
7 files changed, 50 insertions, 50 deletions
diff --git a/Modules/_sqlite/cache.c b/Modules/_sqlite/cache.c index 85118fc..3362a5c 100644 --- a/Modules/_sqlite/cache.c +++ b/Modules/_sqlite/cache.c @@ -241,12 +241,12 @@ PyObject* pysqlite_cache_display(pysqlite_Cache* self, PyObject* args) if (!fmt_args) { return NULL; } - template = PyString_FromString("%s <- %s ->%s\n"); + template = PyBytes_FromString("%s <- %s ->%s\n"); if (!template) { Py_DECREF(fmt_args); return NULL; } - display_str = PyString_Format(template, fmt_args); + display_str = PyBytes_Format(template, fmt_args); Py_DECREF(template); Py_DECREF(fmt_args); if (!display_str) { diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c index 8269e0b..927c983 100644 --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -84,8 +84,8 @@ int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject Py_INCREF(&PyUnicode_Type); self->text_factory = (PyObject*)&PyUnicode_Type; - if (PyString_Check(database) || PyUnicode_Check(database)) { - if (PyString_Check(database)) { + if (PyBytes_Check(database) || PyUnicode_Check(database)) { + if (PyBytes_Check(database)) { database_utf8 = database; Py_INCREF(database_utf8); } else { @@ -96,7 +96,7 @@ int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject } Py_BEGIN_ALLOW_THREADS - rc = sqlite3_open(PyString_AsString(database_utf8), &self->db); + rc = sqlite3_open(PyBytes_AsString(database_utf8), &self->db); Py_END_ALLOW_THREADS Py_DECREF(database_utf8); @@ -111,7 +111,7 @@ int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject if (class_attr) { class_attr_str = PyObject_Str(class_attr); if (class_attr_str) { - if (strcmp(PyString_AsString(class_attr_str), "<type 'apsw.Connection'>") == 0) { + if (strcmp(PyBytes_AsString(class_attr_str), "<type 'apsw.Connection'>") == 0) { /* In the APSW Connection object, the first entry after * PyObject_HEAD is the sqlite3* we want to get hold of. * Luckily, this is the same layout as we have in our @@ -134,7 +134,7 @@ int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject } if (!isolation_level) { - isolation_level = PyString_FromString(""); + isolation_level = PyBytes_FromString(""); if (!isolation_level) { return -1; } @@ -499,12 +499,12 @@ void _pysqlite_set_result(sqlite3_context* context, PyObject* py_val) } else { sqlite3_result_blob(context, buffer, buflen, SQLITE_TRANSIENT); } - } else if (PyString_Check(py_val)) { - sqlite3_result_text(context, PyString_AsString(py_val), -1, SQLITE_TRANSIENT); + } else if (PyBytes_Check(py_val)) { + sqlite3_result_text(context, PyBytes_AsString(py_val), -1, SQLITE_TRANSIENT); } else if (PyUnicode_Check(py_val)) { stringval = PyUnicode_AsUTF8String(py_val); if (stringval) { - sqlite3_result_text(context, PyString_AsString(stringval), -1, SQLITE_TRANSIENT); + sqlite3_result_text(context, PyBytes_AsString(stringval), -1, SQLITE_TRANSIENT); Py_DECREF(stringval); } } else { @@ -963,21 +963,21 @@ static int pysqlite_connection_set_isolation_level(pysqlite_Connection* self, Py Py_INCREF(isolation_level); self->isolation_level = isolation_level; - begin_statement = PyString_FromString("BEGIN "); + begin_statement = PyBytes_FromString("BEGIN "); if (!begin_statement) { return -1; } - PyString_Concat(&begin_statement, isolation_level); + PyBytes_Concat(&begin_statement, isolation_level); if (!begin_statement) { return -1; } - self->begin_statement = PyMem_Malloc(PyString_Size(begin_statement) + 2); + self->begin_statement = PyMem_Malloc(PyBytes_Size(begin_statement) + 2); if (!self->begin_statement) { return -1; } - strcpy(self->begin_statement, PyString_AsString(begin_statement)); + strcpy(self->begin_statement, PyBytes_AsString(begin_statement)); Py_DECREF(begin_statement); } @@ -1152,8 +1152,8 @@ pysqlite_collation_callback( goto finally; } - string1 = PyString_FromStringAndSize((const char*)text1_data, text1_length); - string2 = PyString_FromStringAndSize((const char*)text2_data, text2_length); + string1 = PyBytes_FromStringAndSize((const char*)text1_data, text1_length); + string2 = PyBytes_FromStringAndSize((const char*)text2_data, text2_length); if (!string1 || !string2) { goto finally; /* failed to allocate strings */ @@ -1259,7 +1259,7 @@ pysqlite_connection_create_collation(pysqlite_Connection* self, PyObject* args) goto finally; } - if (!PyArg_ParseTuple(args, "O!O:create_collation(name, callback)", &PyString_Type, &name, &callable)) { + if (!PyArg_ParseTuple(args, "O!O:create_collation(name, callback)", &PyBytes_Type, &name, &callable)) { goto finally; } @@ -1268,7 +1268,7 @@ pysqlite_connection_create_collation(pysqlite_Connection* self, PyObject* args) goto finally; } - chk = PyString_AsString(uppercase_name); + chk = PyBytes_AsString(uppercase_name); while (*chk) { if ((*chk >= '0' && *chk <= '9') || (*chk >= 'A' && *chk <= 'Z') @@ -1293,7 +1293,7 @@ pysqlite_connection_create_collation(pysqlite_Connection* self, PyObject* args) } rc = sqlite3_create_collation(self->db, - PyString_AsString(uppercase_name), + PyBytes_AsString(uppercase_name), SQLITE_UTF8, (callable != Py_None) ? callable : NULL, (callable != Py_None) ? pysqlite_collation_callback : NULL); diff --git a/Modules/_sqlite/connection.h b/Modules/_sqlite/connection.h index 3b1c632..c5d0fd0 100644 --- a/Modules/_sqlite/connection.h +++ b/Modules/_sqlite/connection.h @@ -80,7 +80,7 @@ typedef struct /* Determines how bytestrings from SQLite are converted to Python objects: * - PyUnicode_Type: Python Unicode objects are constructed from UTF-8 bytestrings * - OptimizedUnicode: Like before, but for ASCII data, only PyStrings are created. - * - PyString_Type: PyStrings are created as-is. + * - PyBytes_Type: PyStrings are created as-is. * - Any custom callable: Any object returned from the callable called with the bytestring * as single parameter. */ diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c index 308823c..2321fa8 100644 --- a/Modules/_sqlite/cursor.c +++ b/Modules/_sqlite/cursor.c @@ -182,7 +182,7 @@ int pysqlite_build_row_cast_map(pysqlite_Cursor* self) if (*pos == '[') { type_start = pos + 1; } else if (*pos == ']' && type_start != (const char*)-1) { - key = PyString_FromStringAndSize(type_start, pos - type_start); + key = PyBytes_FromStringAndSize(type_start, pos - type_start); if (!key) { /* creating a string failed, but it is too complicated * to propagate the error here, we just assume there is @@ -207,7 +207,7 @@ int pysqlite_build_row_cast_map(pysqlite_Cursor* self) * 'NUMBER(10)' to be treated as 'NUMBER', for example. * In other words, it will work as people expect it to work.*/ if (*pos == ' ' || *pos == '(' || *pos == 0) { - py_decltype = PyString_FromStringAndSize(decltype, pos - decltype); + py_decltype = PyBytes_FromStringAndSize(decltype, pos - decltype); if (!py_decltype) { return -1; } @@ -252,7 +252,7 @@ PyObject* _pysqlite_build_column_name(const char* colname) if ((*pos == '[') && (pos > colname) && (*(pos-1) == ' ')) { pos--; } - return PyString_FromStringAndSize(colname, pos - colname); + return PyBytes_FromStringAndSize(colname, pos - colname); } } } @@ -277,7 +277,7 @@ PyObject* pysqlite_unicode_from_string(const char* val_str, int optimize) } if (is_ascii) { - return PyString_FromString(val_str); + return PyBytes_FromString(val_str); } else { return PyUnicode_DecodeUTF8(val_str, strlen(val_str), NULL); } @@ -331,7 +331,7 @@ PyObject* _pysqlite_fetch_one_row(pysqlite_Cursor* self) Py_INCREF(Py_None); converted = Py_None; } else { - item = PyString_FromStringAndSize(val_str, nbytes); + item = PyBytes_FromStringAndSize(val_str, nbytes); if (!item) { return NULL; } @@ -374,8 +374,8 @@ PyObject* _pysqlite_fetch_one_row(pysqlite_Cursor* self) colname , val_str); PyErr_SetString(pysqlite_OperationalError, buf); } - } 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_FromString(val_str); } else { converted = PyObject_CallFunction(self->connection->text_factory, "s", val_str); } @@ -446,7 +446,7 @@ PyObject* _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* return NULL; } - if (!PyString_Check(operation) && !PyUnicode_Check(operation)) { + if (!PyBytes_Check(operation) && !PyUnicode_Check(operation)) { PyErr_SetString(PyExc_ValueError, "operation parameter must be str or unicode"); return NULL; } @@ -468,7 +468,7 @@ PyObject* _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* return NULL; } - if (!PyString_Check(operation) && !PyUnicode_Check(operation)) { + if (!PyBytes_Check(operation) && !PyUnicode_Check(operation)) { PyErr_SetString(PyExc_ValueError, "operation parameter must be str or unicode"); return NULL; } @@ -503,15 +503,15 @@ PyObject* _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* rc = pysqlite_statement_reset(self->statement); } - if (PyString_Check(operation)) { - operation_cstr = PyString_AsString(operation); + if (PyBytes_Check(operation)) { + operation_cstr = PyBytes_AsString(operation); } else { operation_bytestr = PyUnicode_AsUTF8String(operation); if (!operation_bytestr) { goto error; } - operation_cstr = PyString_AsString(operation_bytestr); + operation_cstr = PyBytes_AsString(operation_bytestr); } /* reset description */ @@ -768,15 +768,15 @@ PyObject* pysqlite_cursor_executescript(pysqlite_Cursor* self, PyObject* args) return NULL; } - if (PyString_Check(script_obj)) { - script_cstr = PyString_AsString(script_obj); + if (PyBytes_Check(script_obj)) { + script_cstr = PyBytes_AsString(script_obj); } else if (PyUnicode_Check(script_obj)) { script_str = PyUnicode_AsUTF8String(script_obj); if (!script_str) { return NULL; } - script_cstr = PyString_AsString(script_str); + script_cstr = PyBytes_AsString(script_str); } else { PyErr_SetString(PyExc_ValueError, "script argument must be unicode or string."); return NULL; diff --git a/Modules/_sqlite/module.c b/Modules/_sqlite/module.c index af7eace..f77452c 100644 --- a/Modules/_sqlite/module.c +++ b/Modules/_sqlite/module.c @@ -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 == &PyInt_Type || type == &PyLong_Type || type == &PyFloat_Type - || type == &PyString_Type || type == &PyUnicode_Type || type == &PyBuffer_Type) { + || type == &PyBytes_Type || type == &PyUnicode_Type || type == &PyBuffer_Type) { pysqlite_BaseTypeAdapted = 1; } @@ -367,13 +367,13 @@ PyMODINIT_FUNC init_sqlite3(void) Py_DECREF(tmp_obj); } - if (!(tmp_obj = PyString_FromString(PYSQLITE_VERSION))) { + if (!(tmp_obj = PyBytes_FromString(PYSQLITE_VERSION))) { goto error; } PyDict_SetItemString(dict, "version", tmp_obj); Py_DECREF(tmp_obj); - if (!(tmp_obj = PyString_FromString(sqlite3_libversion()))) { + if (!(tmp_obj = PyBytes_FromString(sqlite3_libversion()))) { goto error; } PyDict_SetItemString(dict, "sqlite_version", tmp_obj); diff --git a/Modules/_sqlite/row.c b/Modules/_sqlite/row.c index 3419267..8815116 100644 --- a/Modules/_sqlite/row.c +++ b/Modules/_sqlite/row.c @@ -86,13 +86,13 @@ PyObject* pysqlite_row_subscript(pysqlite_Row* self, PyObject* idx) item = PyTuple_GetItem(self->data, _idx); Py_XINCREF(item); return item; - } else if (PyString_Check(idx)) { - key = PyString_AsString(idx); + } else if (PyBytes_Check(idx)) { + key = PyBytes_AsString(idx); nitems = PyTuple_Size(self->description); for (i = 0; i < nitems; i++) { - compare_key = PyString_AsString(PyTuple_GET_ITEM(PyTuple_GET_ITEM(self->description, i), 0)); + compare_key = PyBytes_AsString(PyTuple_GET_ITEM(PyTuple_GET_ITEM(self->description, i), 0)); if (!compare_key) { return NULL; } diff --git a/Modules/_sqlite/statement.c b/Modules/_sqlite/statement.c index 0e77668..b9245f7 100644 --- a/Modules/_sqlite/statement.c +++ b/Modules/_sqlite/statement.c @@ -60,7 +60,7 @@ int pysqlite_statement_create(pysqlite_Statement* self, pysqlite_Connection* con self->st = NULL; self->in_use = 0; - if (PyString_Check(sql)) { + if (PyBytes_Check(sql)) { sql_str = sql; Py_INCREF(sql_str); } else if (PyUnicode_Check(sql)) { @@ -77,7 +77,7 @@ int pysqlite_statement_create(pysqlite_Statement* self, pysqlite_Connection* con self->in_weakreflist = NULL; self->sql = sql_str; - sql_cstr = PyString_AsString(sql_str); + sql_cstr = PyBytes_AsString(sql_str); rc = sqlite3_prepare(connection->db, sql_cstr, @@ -119,7 +119,7 @@ int pysqlite_statement_bind_parameter(pysqlite_Statement* self, int pos, PyObjec paramtype = TYPE_LONG; } else if (PyFloat_CheckExact(parameter)) { paramtype = TYPE_FLOAT; - } else if (PyString_CheckExact(parameter)) { + } else if (PyBytes_CheckExact(parameter)) { paramtype = TYPE_STRING; } else if (PyUnicode_CheckExact(parameter)) { paramtype = TYPE_UNICODE; @@ -131,7 +131,7 @@ int pysqlite_statement_bind_parameter(pysqlite_Statement* self, int pos, PyObjec paramtype = TYPE_LONG; } else if (PyFloat_Check(parameter)) { paramtype = TYPE_FLOAT; - } else if (PyString_Check(parameter)) { + } else if (PyBytes_Check(parameter)) { paramtype = TYPE_STRING; } else if (PyUnicode_Check(parameter)) { paramtype = TYPE_UNICODE; @@ -140,7 +140,7 @@ int pysqlite_statement_bind_parameter(pysqlite_Statement* self, int pos, PyObjec } if (paramtype == TYPE_STRING && !allow_8bit_chars) { - string = PyString_AS_STRING(parameter); + string = PyBytes_AS_STRING(parameter); for (c = string; *c != 0; c++) { if (*c & 0x80) { PyErr_SetString(pysqlite_ProgrammingError, "You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings."); @@ -164,12 +164,12 @@ int pysqlite_statement_bind_parameter(pysqlite_Statement* self, int pos, PyObjec rc = sqlite3_bind_double(self->st, pos, PyFloat_AsDouble(parameter)); break; case TYPE_STRING: - string = PyString_AS_STRING(parameter); + string = PyBytes_AS_STRING(parameter); rc = sqlite3_bind_text(self->st, pos, string, -1, SQLITE_TRANSIENT); break; case TYPE_UNICODE: stringval = PyUnicode_AsUTF8String(parameter); - string = PyString_AsString(stringval); + string = PyBytes_AsString(stringval); rc = sqlite3_bind_text(self->st, pos, string, -1, SQLITE_TRANSIENT); Py_DECREF(stringval); break; @@ -197,7 +197,7 @@ static int _need_adapt(PyObject* obj) } if (PyInt_CheckExact(obj) || PyLong_CheckExact(obj) - || PyFloat_CheckExact(obj) || PyString_CheckExact(obj) + || PyFloat_CheckExact(obj) || PyBytes_CheckExact(obj) || PyUnicode_CheckExact(obj) || PyBuffer_Check(obj)) { return 0; } else { @@ -326,7 +326,7 @@ int pysqlite_statement_recompile(pysqlite_Statement* self, PyObject* params) char* sql_cstr; sqlite3_stmt* new_st; - sql_cstr = PyString_AsString(self->sql); + sql_cstr = PyBytes_AsString(self->sql); rc = sqlite3_prepare(self->db, sql_cstr, |