mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
Correctly handle None for protocol in adapt(..) (#5979)
This commit is contained in:
1 parent
a54873d302
commit
6d2152cafe
2 files changed
+8
-3
No files matched your search
Vendored
-2
@@ -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)
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in new issue
Block a user