Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3a85732

Browse files
committed
Issue #18488: Fix _pysqlite_final_callback()
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().
1 parent db53ad7 commit 3a85732

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

Modules/_sqlite/connection.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -718,10 +718,6 @@ void _pysqlite_final_callback(sqlite3_context* context)
718718

719719
function_result = _PyObject_CallMethodId(*aggregate_instance, &PyId_finalize, "");
720720

721-
/* Restore the exception (if any) of the last call to step(),
722-
but clear also the current exception if finalize() failed */
723-
PyErr_Restore(exception, value, tb);
724-
725721
Py_DECREF(*aggregate_instance);
726722

727723
ok = 0;
@@ -738,6 +734,10 @@ void _pysqlite_final_callback(sqlite3_context* context)
738734
_sqlite3_result_error(context, "user-defined aggregate's 'finalize' method raised error", -1);
739735
}
740736

737+
/* Restore the exception (if any) of the last call to step(),
738+
but clear also the current exception if finalize() failed */
739+
PyErr_Restore(exception, value, tb);
740+
741741
error:
742742
#ifdef WITH_THREAD
743743
PyGILState_Release(threadstate);

0 commit comments

Comments
 (0)