Skip to content

Commit 6d2152c

Browse files
authored
Correctly handle None for protocol in adapt(..) (#5979)
1 parent a54873d commit 6d2152c

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

Lib/test/test_sqlite3/test_types.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,8 +433,6 @@ def test_missing_adapter(self):
433433
with self.assertRaises(sqlite.ProgrammingError):
434434
sqlite.adapt(1.) # No float adapter registered
435435

436-
# TODO: RUSTPYTHON
437-
@unittest.expectedFailure
438436
def test_missing_protocol(self):
439437
with self.assertRaises(sqlite.ProgrammingError):
440438
sqlite.adapt(1, None)

stdlib/src/sqlite.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,14 @@ mod _sqlite {
732732
alt: OptionalArg<PyObjectRef>,
733733
vm: &VirtualMachine,
734734
) -> PyResult {
735-
// TODO: None proto
735+
if matches!(proto, OptionalArg::Present(None)) {
736+
return if let OptionalArg::Present(alt) = alt {
737+
Ok(alt)
738+
} else {
739+
Err(new_programming_error(vm, "can't adapt".to_owned()))
740+
};
741+
}
742+
736743
let proto = proto
737744
.flatten()
738745
.unwrap_or_else(|| PrepareProtocol::class(&vm.ctx).to_owned());

0 commit comments

Comments
 (0)