sqlite3: fix row_factory deletion error (#8693)

Match CPython 3.14 by distinguishing row_factory assignment from deletion and raising AttributeError with the compatible message. Unmark the passing row_factory deletion test.

Assisted-by: GitHub Copilot:GPT-5.6 Luna (high)
This commit is contained in:
Jiseok CHOI authored and GitHub committed 2026-09-12 15:51:06 +00:00
1 parent a2e2bd299e
commit 407ba437cd
2 files changed
+14 -3

No files matched your search

-1
View File
@@ -159,7 +159,6 @@ class RowFactoryTests(MemoryDatabaseMixin, unittest.TestCase):
with self.assertRaises(IndexError):
row[complex()] # index must be int or string
@unittest.expectedFailure # TODO: RUSTPYTHON; TypeError: can't delete attribute
def test_delete_connection_row_factory(self):
# gh-149738: deleting row_factory should raise an exception
with self.assertRaises(AttributeError):
+14 -2
View File
@@ -1661,8 +1661,20 @@ mod _sqlite3 {
self.row_factory.to_owned()
}
#[pygetset(setter)]
fn set_row_factory(&self, val: Option<PyObjectRef>) {
let _ = unsafe { self.row_factory.swap(val) };
fn set_row_factory(
&self,
val: PySetterValue<Option<PyObjectRef>>,
vm: &VirtualMachine,
) -> PyResult<()> {
match val {
PySetterValue::Assign(val) => {
let _ = unsafe { self.row_factory.swap(val) };
Ok(())
}
PySetterValue::Delete => {
Err(vm.new_attribute_error("cannot delete row_factory attribute"))
}
}
}
fn check_thread(&self, vm: &VirtualMachine) -> PyResult<()> {