diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2013-08-01 23:48:10 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2013-08-01 23:48:10 (GMT) |
commit | ffff7631610c68691a214e5d463f8454b9c2af74 (patch) | |
tree | f356a2173eccb245bd033541174d890a64fe0f65 | |
parent | 044c516854fa93de4417518bd406498844a2c450 (diff) | |
download | cpython-ffff7631610c68691a214e5d463f8454b9c2af74.zip cpython-ffff7631610c68691a214e5d463f8454b9c2af74.tar.gz cpython-ffff7631610c68691a214e5d463f8454b9c2af74.tar.bz2 |
Issue #18519: Fix test_sqlite on old versions of libsqlite3
With old SQLite versions, _sqlite3_result_error() sets a new Python exception,
so don't restore the previous exception.
-rw-r--r-- | Modules/_sqlite/connection.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c index b56ddac..f5e0428 100644 --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -698,6 +698,7 @@ void _pysqlite_final_callback(sqlite3_context* context) _Py_IDENTIFIER(finalize); int ok; PyObject *exception, *value, *tb; + int restore; #ifdef WITH_THREAD PyGILState_STATE threadstate; @@ -715,6 +716,7 @@ void _pysqlite_final_callback(sqlite3_context* context) /* Keep the exception (if any) of the last call to step() */ PyErr_Fetch(&exception, &value, &tb); + restore = 1; function_result = _PyObject_CallMethodId(*aggregate_instance, &PyId_finalize, ""); @@ -732,11 +734,18 @@ void _pysqlite_final_callback(sqlite3_context* context) PyErr_Clear(); } _sqlite3_result_error(context, "user-defined aggregate's 'finalize' method raised error", -1); +#if SQLITE_VERSION_NUMBER < 3003003 + /* with old SQLite versions, _sqlite3_result_error() sets a new Python + exception, so don't restore the previous exception */ + restore = 0; +#endif } - /* 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); + if (restore) { + /* 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 |