From 925221c9fad0631ce3e0799855560c2cab91800f Mon Sep 17 00:00:00 2001 From: Charles Leifer Date: Tue, 4 Feb 2020 07:32:59 -0600 Subject: [PATCH] Merge upstream changes. --- src/cursor.c | 31 +++++++------------------------ src/module.c | 4 ++-- 2 files changed, 9 insertions(+), 26 deletions(-) diff --git a/src/cursor.c b/src/cursor.c index caa7b5e..1941786 100644 --- a/src/cursor.c +++ b/src/cursor.c @@ -611,7 +611,6 @@ static PyObject * pysqlite_cursor_executescript(pysqlite_Cursor* self, PyObject* args) { PyObject* script_obj; - PyObject* script_str = NULL; const char* script_cstr; sqlite3_stmt* statement; int rc; @@ -685,8 +684,6 @@ pysqlite_cursor_executescript(pysqlite_Cursor* self, PyObject* args) } error: - Py_XDECREF(script_str); - if (PyErr_Occurred()) { return NULL; } else { @@ -773,7 +770,7 @@ PyObject* pysqlite_cursor_fetchone(pysqlite_Cursor* self, PyObject* args) PyObject* pysqlite_cursor_fetchmany(pysqlite_Cursor* self, PyObject* args, PyObject* kwargs) { - static char *kwlist[] = {"size", NULL, NULL}; + static char *kwlist[] = {"size", NULL}; PyObject* row; PyObject* list; @@ -789,17 +786,9 @@ PyObject* pysqlite_cursor_fetchmany(pysqlite_Cursor* self, PyObject* args, PyObj return NULL; } - /* just make sure we enter the loop */ - row = Py_None; - - while (row) { - row = pysqlite_cursor_iternext(self); - if (row) { - PyList_Append(list, row); - Py_DECREF(row); - } else { - break; - } + while ((row = pysqlite_cursor_iternext(self))) { + PyList_Append(list, row); + Py_XDECREF(row); if (++counter == maxrows) { break; @@ -824,15 +813,9 @@ PyObject* pysqlite_cursor_fetchall(pysqlite_Cursor* self, PyObject* args) return NULL; } - /* just make sure we enter the loop */ - row = (PyObject*)Py_None; - - while (row) { - row = pysqlite_cursor_iternext(self); - if (row) { - PyList_Append(list, row); - Py_DECREF(row); - } + while ((row = pysqlite_cursor_iternext(self))) { + PyList_Append(list, row); + Py_XDECREF(row); } if (PyErr_Occurred()) { diff --git a/src/module.c b/src/module.c index 7ba9e42..6659d33 100644 --- a/src/module.c +++ b/src/module.c @@ -105,7 +105,7 @@ RAM instead of on disk."); static PyObject* module_complete(PyObject* self, PyObject* args, PyObject* kwargs) { - static char *kwlist[] = {"statement", NULL, NULL}; + static char *kwlist[] = {"statement", NULL}; char* statement; PyObject* result; @@ -135,7 +135,7 @@ Checks if a string contains a complete SQL statement. Non-standard."); static PyObject* module_enable_shared_cache(PyObject* self, PyObject* args, PyObject* kwargs) { - static char *kwlist[] = {"do_enable", NULL, NULL}; + static char *kwlist[] = {"do_enable", NULL}; int do_enable; int rc;