diff --git a/Lib/test/test_sqlite3/test_hooks.py b/Lib/test/test_sqlite3/test_hooks.py index 1ab62688c..21042b9bf 100644 --- a/Lib/test/test_sqlite3/test_hooks.py +++ b/Lib/test/test_sqlite3/test_hooks.py @@ -36,8 +36,6 @@ class CollationTests(unittest.TestCase): with self.assertRaises(TypeError): con.create_collation(None, lambda x, y: (x > y) - (x < y)) - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_create_collation_not_callable(self): con = sqlite.connect(":memory:") with self.assertRaises(TypeError) as cm: diff --git a/stdlib/src/sqlite.rs b/stdlib/src/sqlite.rs index 9fae91fd6..046893e78 100644 --- a/stdlib/src/sqlite.rs +++ b/stdlib/src/sqlite.rs @@ -1107,7 +1107,7 @@ mod _sqlite { ) -> PyResult<()> { let name = name.to_cstring(vm)?; let db = self.db_lock(vm)?; - let Some(data )= CallbackData::new(callable, vm) else { + let Some(data) = CallbackData::new(callable.clone(), vm) else { unsafe { sqlite3_create_collation_v2(db.db, name.as_ptr(), SQLITE_UTF8, null_mut(), None, None); } @@ -1115,6 +1115,10 @@ mod _sqlite { }; let data = Box::into_raw(Box::new(data)); + if !callable.is_callable() { + return Err(vm.new_type_error("parameter must be callable".to_owned())); + } + let ret = unsafe { sqlite3_create_collation_v2( db.db,