Erlend Egeberg Aasland <erlend.aasl...@innova.no> added the comment:

There are six users of pysqlite_step():

$ grep -nrE "\<pysqlite_step\>" Modules/_sqlite
Modules/_sqlite/util.c:27:int pysqlite_step(sqlite3_stmt* statement, 
pysqlite_Connection* connection)
Modules/_sqlite/connection.c:393:    rc = pysqlite_step(statement, self);
Modules/_sqlite/connection.c:442:        rc = pysqlite_step(statement, self);
Modules/_sqlite/connection.c:493:        rc = pysqlite_step(statement, self);
Modules/_sqlite/util.h:32:int pysqlite_step(sqlite3_stmt* statement, 
pysqlite_Connection* connection);
Modules/_sqlite/cursor.c:519:        rc = pysqlite_step(self->statement->st, 
self->connection);
Modules/_sqlite/cursor.c:715:            rc = pysqlite_step(statement, 
self->connection);
Modules/_sqlite/cursor.c:787:        rc = pysqlite_step(self->statement->st, 
self->connection);

The three users in Modules/_sqlite/connection.c — _pysqlite_connection_begin(), 
pysqlite_connection_commit_impl(), and pysqlite_connection_rollback_impl() – 
are all ok, following this pattern:
1) prepare the statement
2) verify that prepare was successful, bail if not
3) call step

pysqlite_cursor_executescript() (line 715 in Modules/_sqlite/cursor.c) is also 
ok:
1) prepare the statement
2) verify that prepare was successful, bail if not
3) call step until there are no more rows

I need a little bit more time to verify _pysqlite_query_execute() and 
pysqlite_cursor_iternext().



Note to self: pysqlite_cursor_executescript() calls sqlite3_finalize() three 
times. It would have been better to break out of the loop when rc != 
SQLITE_ROW, immediately call sqlite3_finalize() (error code is preserved if 
sqlite3_step() failed), and then check rc and PyErr_Occurred(). It will make 
the code easier to follow, IMO.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue43290>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to