Commit ada439f3 authored by Victor Stinner's avatar Victor Stinner

Issue #18488: _pysqlite_final_callback() should not clear the exception set by

the last call to the step() method of a user function
parent f725daba
...@@ -697,6 +697,7 @@ void _pysqlite_final_callback(sqlite3_context* context) ...@@ -697,6 +697,7 @@ void _pysqlite_final_callback(sqlite3_context* context)
PyObject** aggregate_instance; PyObject** aggregate_instance;
_Py_IDENTIFIER(finalize); _Py_IDENTIFIER(finalize);
int ok; int ok;
PyObject *exception, *value, *tb;
#ifdef WITH_THREAD #ifdef WITH_THREAD
PyGILState_STATE threadstate; PyGILState_STATE threadstate;
...@@ -712,7 +713,15 @@ void _pysqlite_final_callback(sqlite3_context* context) ...@@ -712,7 +713,15 @@ void _pysqlite_final_callback(sqlite3_context* context)
goto error; goto error;
} }
/* Keep the exception (if any) of the last call to step() */
PyErr_Fetch(&exception, &value, &tb);
function_result = _PyObject_CallMethodId(*aggregate_instance, &PyId_finalize, ""); function_result = _PyObject_CallMethodId(*aggregate_instance, &PyId_finalize, "");
/* Restore the exception (if any) of the last call to step(),
but clear also the current exception if finalize() failed */
PyErr_Restore(exception, value, tb);
Py_DECREF(*aggregate_instance); Py_DECREF(*aggregate_instance);
ok = 0; ok = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment