fix(sqlite): align adaptation protocol with CPython (#5964)

This commit is contained in:
Jiseok CHOI authored and GitHub committed 2025-07-14 14:22:52 +09:00
1 parent 97e85b220e
commit 5ab64b7002
2 files changed
+10 -6

No files matched your search

-4
View File
@@ -439,8 +439,6 @@ class ObjectAdaptationTests(unittest.TestCase):
with self.assertRaises(sqlite.ProgrammingError):
sqlite.adapt(1, None)
# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_defect_proto(self):
class DefectProto():
def __adapt__(self):
@@ -448,8 +446,6 @@ class ObjectAdaptationTests(unittest.TestCase):
with self.assertRaises(sqlite.ProgrammingError):
sqlite.adapt(1., DefectProto)
# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_defect_self_adapt(self):
class DefectSelfAdapt(float):
def __conform__(self, _):
+10 -2
View File
@@ -695,7 +695,11 @@ mod _sqlite {
}
if let Ok(adapter) = proto.get_attr("__adapt__", vm) {
match adapter.call((obj,), vm) {
Ok(val) => return Ok(val),
Ok(val) => {
if !vm.is_none(&val) {
return Ok(val);
}
}
Err(exc) => {
if !exc.fast_isinstance(vm.ctx.exceptions.type_error) {
return Err(exc);
@@ -705,7 +709,11 @@ mod _sqlite {
}
if let Ok(adapter) = obj.get_attr("__conform__", vm) {
match adapter.call((proto,), vm) {
Ok(val) => return Ok(val),
Ok(val) => {
if !vm.is_none(&val) {
return Ok(val);
}
}
Err(exc) => {
if !exc.fast_isinstance(vm.ctx.exceptions.type_error) {
return Err(exc);