summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-11-05 14:50:30 +0100
committerVictor Stinner <victor.stinner@gmail.com>2013-11-05 14:50:30 +0100
commitcf241142eb55372a12deed0b80b4935b80ee7776 (patch)
tree11802875348ef1d9468a7d718a7dc84c9d2006f1
parent373d95d6d9ff9eef1d2e63c0390095988ebcdbdb (diff)
downloadcpython-cf241142eb55372a12deed0b80b4935b80ee7776.tar.gz
Issue #19437: Fix pysqlite_cursor_iternext() of sqlite3, when the row factory
fails, don't consume the row (restore it) and fail immediatly (don't call pysqlite_step())
-rw-r--r--Modules/_sqlite/cursor.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c
index cf7f9d3242..8d10890eb0 100644
--- a/Modules/_sqlite/cursor.c
+++ b/Modules/_sqlite/cursor.c
@@ -871,10 +871,15 @@ PyObject* pysqlite_cursor_iternext(pysqlite_Cursor *self)
}
next_row_tuple = self->next_row;
+ assert(next_row_tuple != NULL);
self->next_row = NULL;
if (self->row_factory != Py_None) {
next_row = PyObject_CallFunction(self->row_factory, "OO", self, next_row_tuple);
+ if (next_row == NULL) {
+ self->next_row = next_row_tuple;
+ return NULL;
+ }
Py_DECREF(next_row_tuple);
} else {
next_row = next_row_tuple;