Skip to content
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
Modules/_sqlite/connection.c
  • Loading branch information
iritkatriel committed Feb 24, 2023
commit c7ce7f69107370785e31a4fcb07c840dd47c3374
14 changes: 6 additions & 8 deletions Modules/_sqlite/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,6 @@ final_callback(sqlite3_context *context)
PyObject* function_result;
PyObject** aggregate_instance;
int ok;
PyObject *exception, *value, *tb;

aggregate_instance = (PyObject**)sqlite3_aggregate_context(context, 0);
if (aggregate_instance == NULL) {
Expand All @@ -923,7 +922,7 @@ final_callback(sqlite3_context *context)
}

// Keep the exception (if any) of the last call to step, value, or inverse
PyErr_Fetch(&exception, &value, &tb);
PyObject *exc = PyErr_GetRaisedException();

callback_context *ctx = (callback_context *)sqlite3_user_data(context);
assert(ctx != NULL);
Expand All @@ -938,7 +937,7 @@ final_callback(sqlite3_context *context)
}
if (!ok) {
int attr_err = PyErr_ExceptionMatches(PyExc_AttributeError);
_PyErr_ChainExceptions(exception, value, tb);
_PyErr_ChainExceptions1(exc);

/* Note: contrary to the step, value, and inverse callbacks, SQLite
* does _not_, as of SQLite 3.38.0, propagate errors to sqlite3_step()
Expand All @@ -949,7 +948,7 @@ final_callback(sqlite3_context *context)
: "user-defined aggregate's 'finalize' method raised error");
}
else {
PyErr_Restore(exception, value, tb);
PyErr_SetRaisedException(exc);
}

error:
Expand Down Expand Up @@ -2274,15 +2273,14 @@ pysqlite_connection_exit_impl(pysqlite_Connection *self, PyObject *exc_type,
if (commit) {
/* Commit failed; try to rollback in order to unlock the database.
* If rollback also fails, chain the exceptions. */
PyObject *exc, *val, *tb;
PyErr_Fetch(&exc, &val, &tb);
PyObject *exc = PyErr_GetRaisedException();
result = pysqlite_connection_rollback_impl(self);
if (result == NULL) {
_PyErr_ChainExceptions(exc, val, tb);
_PyErr_ChainExceptions1(exc);
}
else {
Py_DECREF(result);
PyErr_Restore(exc, val, tb);
PyErr_SetRaisedException(exc);
}
}
return NULL;
Expand Down