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.c40
1 files changed, 11 insertions, 29 deletions
diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c
index 30c2206ae6..09c13d4dbd 100644
--- a/Modules/_sqlite/cursor.c
+++ b/Modules/_sqlite/cursor.c
@@ -118,11 +118,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);
}
@@ -144,8 +142,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;
}
@@ -231,8 +230,7 @@ int pysqlite_build_row_cast_map(pysqlite_Cursor* self)
if (converter != Py_None) {
Py_DECREF(converter);
}
- Py_XDECREF(self->row_cast_map);
- self->row_cast_map = NULL;
+ Py_CLEAR(self->row_cast_map);
return -1;
}
@@ -260,11 +258,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
*
@@ -342,12 +335,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) {
@@ -445,7 +434,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;
@@ -454,12 +442,7 @@ 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;
+ Py_CLEAR(self->next_row);
if (multiple) {
/* executemany() */
@@ -521,7 +504,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);
@@ -616,7 +599,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;
}
@@ -727,7 +710,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);
}
@@ -875,8 +858,7 @@ PyObject* pysqlite_cursor_iternext(pysqlite_Cursor *self)
if (!self->next_row) {
if (self->statement) {
(void)pysqlite_statement_reset(self->statement);
- Py_DECREF(self->statement);
- self->statement = NULL;
+ Py_CLEAR(self->statement);
}
return NULL;
}