]> granicus.if.org Git - python/commitdiff
Issue #18488: Fix _pysqlite_final_callback()
authorVictor Stinner <victor.stinner@gmail.com>
Mon, 22 Jul 2013 06:34:32 +0000 (08:34 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Mon, 22 Jul 2013 06:34:32 +0000 (08:34 +0200)
Restore behaviour of Python 3.3: print the finalizer() error if
sqlite3.enable_callback_tracebacks() has been called, clear the error
otherwise.

But keep (save/restore) also the AttributeError raised in
_pysqlite_step_callback().

Modules/_sqlite/connection.c

index ed4ae1c197ef27570f709534a010a0b116336ec6..551431c0dbf8c5171ebf39326e4fa1c348148fab 100644 (file)
@@ -718,10 +718,6 @@ void _pysqlite_final_callback(sqlite3_context* context)
 
     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;
@@ -738,6 +734,10 @@ void _pysqlite_final_callback(sqlite3_context* context)
         _sqlite3_result_error(context, "user-defined aggregate's 'finalize' method raised error", -1);
     }
 
+    /* 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);
+
 error:
 #ifdef WITH_THREAD
     PyGILState_Release(threadstate);