Skip to content

Commit f9f5416

Browse files
committed
add assertions
1 parent ae2a5de commit f9f5416

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Modules/_sqlite/cursor.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -926,14 +926,17 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation
926926
}
927927

928928
assert(!sqlite3_stmt_busy(self->statement->st));
929+
assert(multiple || Py_IS_TYPE(parameters_iter, &PyListIter_Type));
930+
929931
while (1) {
930932
parameters = PyIter_Next(parameters_iter);
931933
if (!parameters) {
934+
assert(multiple || !PyErr_Occurred());
932935
break;
933936
}
934937
// PyIter_Next() may have a side-effect on the connection's state.
935938
// See: https://github.com/python/cpython/issues/143198.
936-
if (!pysqlite_check_connection(self->connection)) {
939+
if (multiple && !pysqlite_check_connection(self->connection)) {
937940
goto error;
938941
}
939942

@@ -1005,6 +1008,7 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation
10051008
}
10061009

10071010
if (!multiple) {
1011+
assert(!PyErr_Occurred());
10081012
sqlite_int64 lastrowid;
10091013

10101014
Py_BEGIN_ALLOW_THREADS

0 commit comments

Comments
 (0)