Correctly handle None for protocol in adapt(..) (#5979)

This commit is contained in:
Jiseok CHOI authored and GitHub committed 2025-07-16 01:49:53 +09:00
1 parent a54873d302
commit 6d2152cafe
2 files changed
+8 -3

No files matched your search

-2
View File
@@ -433,8 +433,6 @@ class ObjectAdaptationTests(unittest.TestCase):
with self.assertRaises(sqlite.ProgrammingError):
sqlite.adapt(1.) # No float adapter registered
# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_missing_protocol(self):
with self.assertRaises(sqlite.ProgrammingError):
sqlite.adapt(1, None)
+8 -1
View File
@@ -732,7 +732,14 @@ mod _sqlite {
alt: OptionalArg<PyObjectRef>,
vm: &VirtualMachine,
) -> PyResult {
// TODO: None proto
if matches!(proto, OptionalArg::Present(None)) {
return if let OptionalArg::Present(alt) = alt {
Ok(alt)
} else {
Err(new_programming_error(vm, "can't adapt".to_owned()))
};
}
let proto = proto
.flatten()
.unwrap_or_else(|| PrepareProtocol::class(&vm.ctx).to_owned());