mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
fix(sqlite): align adaptation protocol with CPython (#5964)
This commit is contained in:
1 parent
97e85b220e
commit
5ab64b7002
2 files changed
+10
-6
No files matched your search
Vendored
-4
@@ -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
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user