summaryrefslogtreecommitdiffstats
path: root/Modules/_sqlite
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-07-17 23:42:04 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-07-17 23:42:04 (GMT)
commite9af4cfaced93ea9ec37bb448dd57b8c2014bdaf (patch)
tree52658e625c7831c1f3597b7e8db71b6381c7c169 /Modules/_sqlite
parentf97dfd7b59c6472dc209f85c8f0a479dd6649859 (diff)
downloadcpython-e9af4cfaced93ea9ec37bb448dd57b8c2014bdaf.zip
cpython-e9af4cfaced93ea9ec37bb448dd57b8c2014bdaf.tar.gz
cpython-e9af4cfaced93ea9ec37bb448dd57b8c2014bdaf.tar.bz2
Issue #18488: _pysqlite_final_callback() should not clear the exception set by
the last call to the step() method of a user function
Diffstat (limited to 'Modules/_sqlite')
-rw-r--r--Modules/_sqlite/connection.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c
index 04bcdf2..6a58431 100644
--- a/Modules/_sqlite/connection.c
+++ b/Modules/_sqlite/connection.c
@@ -697,6 +697,7 @@ void _pysqlite_final_callback(sqlite3_context* context)
PyObject** aggregate_instance;
_Py_IDENTIFIER(finalize);
int ok;
+ PyObject *exception, *value, *tb;
#ifdef WITH_THREAD
PyGILState_STATE threadstate;
@@ -712,7 +713,15 @@ void _pysqlite_final_callback(sqlite3_context* context)
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, "");
+
+ /* 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);
ok = 0;