summaryrefslogtreecommitdiffstats
path: root/Modules/_sqlite
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/_sqlite')
-rw-r--r--Modules/_sqlite/cache.c3
-rw-r--r--Modules/_sqlite/connection.c26
-rw-r--r--Modules/_sqlite/cursor.c20
-rw-r--r--Modules/_sqlite/module.c13
4 files changed, 24 insertions, 38 deletions
diff --git a/Modules/_sqlite/cache.c b/Modules/_sqlite/cache.c
index 3689a4e..62c5893 100644
--- a/Modules/_sqlite/cache.c
+++ b/Modules/_sqlite/cache.c
@@ -244,8 +244,7 @@ PyObject* pysqlite_cache_display(pysqlite_Cache* self, PyObject* args)
ptr = ptr->next;
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyMethodDef cache_methods[] = {
diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c
index 3c52108..409fa74 100644
--- a/Modules/_sqlite/connection.c
+++ b/Modules/_sqlite/connection.c
@@ -366,8 +366,7 @@ PyObject* pysqlite_connection_close(pysqlite_Connection* self, PyObject* args)
}
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
/*
@@ -874,8 +873,7 @@ PyObject* pysqlite_connection_create_function(pysqlite_Connection* self, PyObjec
if (PyDict_SetItem(self->function_pinboard, func, Py_None) == -1)
return NULL;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
}
@@ -906,8 +904,7 @@ PyObject* pysqlite_connection_create_aggregate(pysqlite_Connection* self, PyObje
if (PyDict_SetItem(self->function_pinboard, aggregate_class, Py_None) == -1)
return NULL;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
}
@@ -1042,8 +1039,7 @@ static PyObject* pysqlite_connection_set_authorizer(pysqlite_Connection* self, P
if (PyDict_SetItem(self->function_pinboard, authorizer_cb, Py_None) == -1)
return NULL;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
}
@@ -1072,8 +1068,7 @@ static PyObject* pysqlite_connection_set_progress_handler(pysqlite_Connection* s
return NULL;
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject* pysqlite_connection_set_trace_callback(pysqlite_Connection* self, PyObject* args, PyObject* kwargs)
@@ -1100,8 +1095,7 @@ static PyObject* pysqlite_connection_set_trace_callback(pysqlite_Connection* sel
sqlite3_trace(self->db, _trace_callback, trace_callback);
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
#ifdef HAVE_LOAD_EXTENSION
@@ -1124,8 +1118,7 @@ static PyObject* pysqlite_enable_load_extension(pysqlite_Connection* self, PyObj
PyErr_SetString(pysqlite_OperationalError, "Error enabling load extension");
return NULL;
} else {
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
}
@@ -1148,8 +1141,7 @@ static PyObject* pysqlite_load_extension(pysqlite_Connection* self, PyObject* ar
PyErr_SetString(pysqlite_OperationalError, errmsg);
return NULL;
} else {
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
}
#endif
@@ -1628,7 +1620,7 @@ pysqlite_connection_exit(pysqlite_Connection* self, PyObject* args)
Py_RETURN_FALSE;
}
-static char connection_doc[] =
+static const char connection_doc[] =
PyDoc_STR("SQLite database connection object.");
static PyGetSetDef connection_getset[] = {
diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c
index e1676de..98eb961 100644
--- a/Modules/_sqlite/cursor.c
+++ b/Modules/_sqlite/cursor.c
@@ -27,7 +27,7 @@
PyObject* pysqlite_cursor_iternext(pysqlite_Cursor* self);
-static char* errmsg_fetch_across_rollback = "Cursor needed to be reset because of commit/rollback and can no longer be fetched from.";
+static const char errmsg_fetch_across_rollback[] = "Cursor needed to be reset because of commit/rollback and can no longer be fetched from.";
static pysqlite_StatementKind detect_statement_type(const char* statement)
{
@@ -242,8 +242,7 @@ PyObject* _pysqlite_build_column_name(const char* colname)
const char* pos;
if (!colname) {
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
for (pos = colname;; pos++) {
@@ -698,7 +697,9 @@ PyObject* _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject*
}
Py_DECREF(self->lastrowid);
- if (!multiple && statement_type == STATEMENT_INSERT) {
+ if (!multiple &&
+ /* REPLACE is an alias for INSERT OR REPLACE */
+ (statement_type == STATEMENT_INSERT || statement_type == STATEMENT_REPLACE)) {
sqlite_int64 lastrowid;
Py_BEGIN_ALLOW_THREADS
lastrowid = sqlite3_last_insert_rowid(self->connection->db);
@@ -913,8 +914,7 @@ PyObject* pysqlite_cursor_fetchone(pysqlite_Cursor* self, PyObject* args)
row = pysqlite_cursor_iternext(self);
if (!row && !PyErr_Occurred()) {
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
return row;
@@ -995,8 +995,7 @@ PyObject* pysqlite_cursor_fetchall(pysqlite_Cursor* self, PyObject* args)
PyObject* pysqlite_noop(pysqlite_Connection* self, PyObject* args)
{
/* don't care, return None */
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
PyObject* pysqlite_cursor_close(pysqlite_Cursor* self, PyObject* args)
@@ -1012,8 +1011,7 @@ PyObject* pysqlite_cursor_close(pysqlite_Cursor* self, PyObject* args)
self->closed = 1;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyMethodDef cursor_methods[] = {
@@ -1049,7 +1047,7 @@ static struct PyMemberDef cursor_members[] =
{NULL}
};
-static char cursor_doc[] =
+static const char cursor_doc[] =
PyDoc_STR("SQLite database cursor class.");
PyTypeObject pysqlite_CursorType = {
diff --git a/Modules/_sqlite/module.c b/Modules/_sqlite/module.c
index 7a7e860..7cd6d2a 100644
--- a/Modules/_sqlite/module.c
+++ b/Modules/_sqlite/module.c
@@ -139,8 +139,7 @@ static PyObject* module_enable_shared_cache(PyObject* self, PyObject* args, PyOb
PyErr_SetString(pysqlite_OperationalError, "Changing the shared_cache flag failed");
return NULL;
} else {
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
}
@@ -172,8 +171,7 @@ static PyObject* module_register_adapter(PyObject* self, PyObject* args)
if (rc == -1)
return NULL;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
PyDoc_STRVAR(module_register_adapter_doc,
@@ -221,8 +219,7 @@ static PyObject* enable_callback_tracebacks(PyObject* self, PyObject* args)
return NULL;
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
PyDoc_STRVAR(enable_callback_tracebacks_doc,
@@ -261,13 +258,13 @@ static PyMethodDef module_methods[] = {
};
struct _IntConstantPair {
- char* constant_name;
+ const char *constant_name;
int constant_value;
};
typedef struct _IntConstantPair IntConstantPair;
-static IntConstantPair _int_constants[] = {
+static const IntConstantPair _int_constants[] = {
{"PARSE_DECLTYPES", PARSE_DECLTYPES},
{"PARSE_COLNAMES", PARSE_COLNAMES},