[3.10] bpo-43853: Expand test suite for SQLite UDF's (GH-27642) (GH-31030)
* [3.10] bpo-43853: Expand test suite for SQLite UDF's (GH-27642).
(cherry picked from commit 3eb3b4f270757f66c7fb6dcf5afa416ee1582a4b)
Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
* Fix test_func_return_too_large_int
GH-27613 (bpo 44839) was not backported, so exceptions differ between
main (3.11) and older versions.
diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c
index 6461039..b669160 100644
--- a/Modules/_sqlite/connection.c
+++ b/Modules/_sqlite/connection.c
@@ -552,7 +552,11 @@ _pysqlite_set_result(sqlite3_context* context, PyObject* py_val)
return -1;
sqlite3_result_int64(context, value);
} else if (PyFloat_Check(py_val)) {
- sqlite3_result_double(context, PyFloat_AsDouble(py_val));
+ double value = PyFloat_AsDouble(py_val);
+ if (value == -1 && PyErr_Occurred()) {
+ return -1;
+ }
+ sqlite3_result_double(context, value);
} else if (PyUnicode_Check(py_val)) {
Py_ssize_t sz;
const char *str = PyUnicode_AsUTF8AndSize(py_val, &sz);