]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-39496: Remove redundant checks from _sqlite/cursor.c (GH-18270)
authorAlex Henrie <alexhenrie24@gmail.com>
Sat, 1 Feb 2020 20:45:34 +0000 (13:45 -0700)
committerGitHub <noreply@github.com>
Sat, 1 Feb 2020 20:45:34 +0000 (23:45 +0300)
Modules/_sqlite/cursor.c

index 2302ca9edac2d8cec3f38e21495daa22a21e89a2..06275ecb26849d9471ab4af900d1c4b90fc2c27f 100644 (file)
@@ -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()) {