summaryrefslogtreecommitdiff
path: root/Modules/_sqlite/cursor.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/_sqlite/cursor.c')
-rw-r--r--Modules/_sqlite/cursor.c31
1 files changed, 8 insertions, 23 deletions
diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c
index 86fbd4ee0d..8a56d3cd80 100644
--- a/Modules/_sqlite/cursor.c
+++ b/Modules/_sqlite/cursor.c
@@ -126,11 +126,9 @@ static int pysqlite_cursor_init(pysqlite_Cursor* self, PyObject* args, PyObject*
static void pysqlite_cursor_dealloc(pysqlite_Cursor* self)
{
- int rc;
-
/* Reset the statement if the user has not closed the cursor */
if (self->statement) {
- rc = pysqlite_statement_reset(self->statement);
+ pysqlite_statement_reset(self->statement);
Py_DECREF(self->statement);
}
@@ -152,8 +150,9 @@ PyObject* _pysqlite_get_converter(PyObject* key)
{
PyObject* upcase_key;
PyObject* retval;
+ _Py_IDENTIFIER(upper);
- upcase_key = PyObject_CallMethod(key, "upper", "");
+ upcase_key = _PyObject_CallMethodId(key, &PyId_upper, "");
if (!upcase_key) {
return NULL;
}
@@ -268,11 +267,6 @@ PyObject* _pysqlite_build_column_name(const char* colname)
}
}
-PyObject* pysqlite_unicode_from_string(const char* val_str, Py_ssize_t size, int optimize)
-{
- return PyUnicode_FromStringAndSize(val_str, size);
-}
-
/*
* Returns a row from the currently active SQLite statement
*
@@ -356,12 +350,8 @@ PyObject* _pysqlite_fetch_one_row(pysqlite_Cursor* self)
} 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, nbytes,
- self->connection->text_factory == pysqlite_OptimizedUnicode ? 1 : 0);
-
+ if (self->connection->text_factory == (PyObject*)&PyUnicode_Type) {
+ converted = PyUnicode_FromStringAndSize(val_str, nbytes);
if (!converted) {
colname = sqlite3_column_name(self->statement->st, i);
if (!colname) {
@@ -460,7 +450,6 @@ PyObject* _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject*
int statement_type;
PyObject* descriptor;
PyObject* second_argument = NULL;
- int allow_8bit_chars;
if (!check_cursor(self)) {
goto error;
@@ -469,10 +458,6 @@ PyObject* _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject*
self->locked = 1;
self->reset = 0;
- /* Make shooting yourself in the foot with not utf-8 decodable 8-bit-strings harder */
- allow_8bit_chars = ((self->connection->text_factory != (PyObject*)&PyUnicode_Type) &&
- (self->connection->text_factory != pysqlite_OptimizedUnicode));
-
Py_XDECREF(self->next_row);
self->next_row = NULL;
@@ -536,7 +521,7 @@ PyObject* _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject*
if (self->statement != NULL) {
/* There is an active statement */
- rc = pysqlite_statement_reset(self->statement);
+ pysqlite_statement_reset(self->statement);
}
operation_cstr = _PyUnicode_AsStringAndSize(operation, &operation_len);
@@ -631,7 +616,7 @@ PyObject* _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject*
pysqlite_statement_mark_dirty(self->statement);
- pysqlite_statement_bind_parameters(self->statement, parameters, allow_8bit_chars);
+ pysqlite_statement_bind_parameters(self->statement, parameters);
if (PyErr_Occurred()) {
goto error;
}
@@ -741,7 +726,7 @@ PyObject* _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject*
}
if (multiple) {
- rc = pysqlite_statement_reset(self->statement);
+ pysqlite_statement_reset(self->statement);
}
Py_XDECREF(parameters);
}