Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 78c7183

Browse files
authored
bpo-39496: Remove redundant checks from _sqlite/cursor.c (GH-18270)
1 parent b94737a commit 78c7183

1 file changed

Lines changed: 6 additions & 20 deletions

File tree

Modules/_sqlite/cursor.c

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -786,17 +786,9 @@ PyObject* pysqlite_cursor_fetchmany(pysqlite_Cursor* self, PyObject* args, PyObj
786786
return NULL;
787787
}
788788

789-
/* just make sure we enter the loop */
790-
row = Py_None;
791-
792-
while (row) {
793-
row = pysqlite_cursor_iternext(self);
794-
if (row) {
795-
PyList_Append(list, row);
796-
Py_DECREF(row);
797-
} else {
798-
break;
799-
}
789+
while ((row = pysqlite_cursor_iternext(self))) {
790+
PyList_Append(list, row);
791+
Py_XDECREF(row);
800792

801793
if (++counter == maxrows) {
802794
break;
@@ -821,15 +813,9 @@ PyObject* pysqlite_cursor_fetchall(pysqlite_Cursor* self, PyObject* args)
821813
return NULL;
822814
}
823815

824-
/* just make sure we enter the loop */
825-
row = (PyObject*)Py_None;
826-
827-
while (row) {
828-
row = pysqlite_cursor_iternext(self);
829-
if (row) {
830-
PyList_Append(list, row);
831-
Py_DECREF(row);
832-
}
816+
while ((row = pysqlite_cursor_iternext(self))) {
817+
PyList_Append(list, row);
818+
Py_XDECREF(row);
833819
}
834820

835821
if (PyErr_Occurred()) {

0 commit comments

Comments
 (0)