[Python-checkins] cpython: Issue #18488: _pysqlite_final_callback() should not clear the exception set by

victor.stinner python-checkins at python.org
Thu Jul 18 01:46:22 CEST 2013


http://hg.python.org/cpython/rev/a2214ab0812e
changeset:   84703:a2214ab0812e
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Thu Jul 18 01:42:04 2013 +0200
summary:
  Issue #18488: _pysqlite_final_callback() should not clear the exception set by
the last call to the step() method of a user function

files:
  Modules/_sqlite/connection.c |  9 +++++++++
  1 files changed, 9 insertions(+), 0 deletions(-)


diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c
--- a/Modules/_sqlite/connection.c
+++ b/Modules/_sqlite/connection.c
@@ -697,6 +697,7 @@
     PyObject** aggregate_instance;
     _Py_IDENTIFIER(finalize);
     int ok;
+    PyObject *exception, *value, *tb;
 
 #ifdef WITH_THREAD
     PyGILState_STATE threadstate;
@@ -712,7 +713,15 @@
         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;

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list