mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
parent
fc3ba6b8fc
commit
023fe334bb
5 changed files with 54 additions and 9 deletions
|
@ -268,9 +268,9 @@ PyObject* _pysqlite_build_column_name(const char* colname)
|
|||
}
|
||||
}
|
||||
|
||||
PyObject* pysqlite_unicode_from_string(const char* val_str, int optimize)
|
||||
PyObject* pysqlite_unicode_from_string(const char* val_str, Py_ssize_t size, int optimize)
|
||||
{
|
||||
return PyUnicode_FromString(val_str);
|
||||
return PyUnicode_FromStringAndSize(val_str, size);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -355,10 +355,11 @@ PyObject* _pysqlite_fetch_one_row(pysqlite_Cursor* self)
|
|||
converted = PyFloat_FromDouble(sqlite3_column_double(self->statement->st, i));
|
||||
} else if (coltype == SQLITE_TEXT) {
|
||||
val_str = (const char*)sqlite3_column_text(self->statement->st, i);
|
||||
nbytes = sqlite3_column_bytes(self->statement->st, i);
|
||||
if ((self->connection->text_factory == (PyObject*)&PyUnicode_Type)
|
||||
|| (self->connection->text_factory == pysqlite_OptimizedUnicode)) {
|
||||
|
||||
converted = pysqlite_unicode_from_string(val_str,
|
||||
converted = pysqlite_unicode_from_string(val_str, nbytes,
|
||||
self->connection->text_factory == pysqlite_OptimizedUnicode ? 1 : 0);
|
||||
|
||||
if (!converted) {
|
||||
|
@ -383,11 +384,11 @@ PyObject* _pysqlite_fetch_one_row(pysqlite_Cursor* self)
|
|||
}
|
||||
}
|
||||
} else if (self->connection->text_factory == (PyObject*)&PyBytes_Type) {
|
||||
converted = PyBytes_FromString(val_str);
|
||||
converted = PyBytes_FromStringAndSize(val_str, nbytes);
|
||||
} else if (self->connection->text_factory == (PyObject*)&PyByteArray_Type) {
|
||||
converted = PyByteArray_FromStringAndSize(val_str, strlen(val_str));
|
||||
converted = PyByteArray_FromStringAndSize(val_str, nbytes);
|
||||
} else {
|
||||
converted = PyObject_CallFunction(self->connection->text_factory, "y", val_str);
|
||||
converted = PyObject_CallFunction(self->connection->text_factory, "y#", val_str, nbytes);
|
||||
}
|
||||
} else {
|
||||
/* coltype == SQLITE_BLOB */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue