bpo-43083: Fix error handling in _sqlite3 (GH-24395)
diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c
index dbe5dd1..370dc1a 100644
--- a/Modules/_sqlite/connection.c
+++ b/Modules/_sqlite/connection.c
@@ -1772,7 +1772,11 @@ pysqlite_connection_create_collation_impl(pysqlite_Connection *self,
(callable != Py_None) ? callable : NULL,
(callable != Py_None) ? pysqlite_collation_callback : NULL);
if (rc != SQLITE_OK) {
- PyDict_DelItem(self->collations, uppercase_name);
+ if (callable != Py_None) {
+ if (PyDict_DelItem(self->collations, uppercase_name) < 0) {
+ PyErr_Clear();
+ }
+ }
_pysqlite_seterror(self->db, NULL);
goto finally;
}