mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
Renamed PyString to PyBytes
This commit is contained in:
parent
9c4756ea26
commit
72b710a596
78 changed files with 983 additions and 983 deletions
|
|
@ -483,7 +483,7 @@ PyObject* _pysqlite_build_py_params(sqlite3_context *context, int argc, sqlite3_
|
|||
break;
|
||||
case SQLITE_BLOB:
|
||||
buflen = sqlite3_value_bytes(cur_value);
|
||||
cur_py_value = PyString_FromStringAndSize(
|
||||
cur_py_value = PyBytes_FromStringAndSize(
|
||||
sqlite3_value_blob(cur_value), buflen);
|
||||
break;
|
||||
case SQLITE_NULL:
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -311,7 +311,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;
|
||||
}
|
||||
|
|
@ -366,8 +366,8 @@ PyObject* _pysqlite_fetch_one_row(pysqlite_Cursor* self)
|
|||
Py_DECREF(buf_bytes);
|
||||
}
|
||||
}
|
||||
} 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 if (self->connection->text_factory == (PyObject*)&PyByteArray_Type) {
|
||||
converted = PyByteArray_FromStringAndSize(val_str, strlen(val_str));
|
||||
} else {
|
||||
|
|
@ -376,7 +376,7 @@ PyObject* _pysqlite_fetch_one_row(pysqlite_Cursor* self)
|
|||
} else {
|
||||
/* coltype == SQLITE_BLOB */
|
||||
nbytes = sqlite3_column_bytes(self->statement->st, i);
|
||||
buffer = PyString_FromStringAndSize(
|
||||
buffer = PyBytes_FromStringAndSize(
|
||||
sqlite3_column_blob(self->statement->st, i), nbytes);
|
||||
if (!buffer) {
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -120,7 +120,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.");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue