pysqlite_connection_commit_impl(), pysqlite_connection_rollback_impl(), and begin_transaction() can be simplified:
sqlite3_finalize() will pass on any error set by sqlite3_step(). This implies that we only need to check the return value of sqlite3_prepare_v2() and sqlite3_finalize(), which implies that we can execute sqlite3_prepare_v2(), sqlite3_step() and sqlite3_finalize() in a row inside a begin/end threads wrapper. As a result, error handling will be greatly simplified.
Fewer lines of code, simpler error paths, increased readability, and increased code coverage.
Activity
erlend-aasland commented on Aug 28, 2021
pysqlite_connection_commit_impl(), pysqlite_connection_rollback_impl(), and begin_transaction() can be simplified:
sqlite3_finalize() will pass on any error set by sqlite3_step(). This implies that we only need to check the return value of sqlite3_prepare_v2() and sqlite3_finalize(), which implies that we can execute sqlite3_prepare_v2(), sqlite3_step() and sqlite3_finalize() in a row inside a begin/end threads wrapper. As a result, error handling will be greatly simplified.
Fewer lines of code, simpler error paths, increased readability, and increased code coverage.
diffstat: 2 files changed, 27 insertions(+), 62 deletions(-)
pablogsal commented on Sep 19, 2021
New changeset 771a546 by Erlend Egeberg Aasland in branch 'main':
bpo-45040: Simplify sqlite3 transaction control functions (GH-28019)
771a546