8000 gh-108083: Don't ignore exceptions in sqlite3.Connection.__init__() and .close() by erlend-aasland · Pull Request #108084 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-108083: Don't ignore exceptions in sqlite3.Connection.__init__() and .close() #108084

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Assert pre/post state in remove_callbacks()
  • Loading branch information
erlend-aasland committed Aug 18, 2023
commit b2d49f3605e6093b27f11b51475b361bdd12504c
14 changes: 8 additions & 6 deletions Modules/_sqlite/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,12 +436,14 @@ free_callback_contexts(pysqlite_Connection *self)
static void
remove_callbacks(sqlite3 *db)
{
if (db == NULL) {
return;
}
sqlite3_trace_v2(db, SQLITE_TRACE_STMT, 0, 0);
assert(db != NULL);
int rc = sqlite3_trace_v2(db, SQLITE_TRACE_STMT, 0, 0);
assert(rc == SQLITE_OK), (void)rc;

sqlite3_progress_handler(db, 0, 0, (void *)0);
(void)sqlite3_set_authorizer(db, NULL, NULL);

rc = sqlite3_set_authorizer(db, NULL, NULL);
assert(rc == SQLITE_OK);
}

static int
Expand Down Expand Up @@ -479,7 +481,7 @@ connection_finalize(PyObject *self)
* tear-down, we must not call back into Python. */
PyInterpreterState *interp = PyInterpreterState_Get();
int teardown = _Py_IsInterpreterFinalizing(interp);
if (teardown) {
if (teardown && con->db) {
remove_callbacks(con->db);
}

Expand Down
0