diff options
author | Alex Henrie <alexhenrie24@gmail.com> | 2020-02-01 20:45:34 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-01 20:45:34 (GMT) |
commit | 78c7183f470b60a39ac2dd0ad1a94d49d1e0b062 (patch) | |
tree | 43759ef9dc4d5d3d577cf292dc4d56c2c36df81f | |
parent | b94737a4af96b29bd4c025724f671e7bc0f6b6f1 (diff) | |
download | cpython-78c7183f470b60a39ac2dd0ad1a94d49d1e0b062.zip cpython-78c7183f470b60a39ac2dd0ad1a94d49d1e0b062.tar.gz cpython-78c7183f470b60a39ac2dd0ad1a94d49d1e0b062.tar.bz2 |
bpo-39496: Remove redundant checks from _sqlite/cursor.c (GH-18270)
-rw-r--r-- | Modules/_sqlite/cursor.c | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c index 2302ca9..06275ec 100644 --- a/Modules/_sqlite/cursor.c +++ b/Modules/_sqlite/cursor.c @@ -786,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; @@ -821,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()) { |