sqlite: Align Connection.__call__ error handling with CPython (#6042)

This commit is contained in:
Jiseok CHOI authored and GitHub committed 2025-07-30 14:05:17 +09:00
1 parent cee579e7ea
commit 1e6da5f430
2 files changed
+6 -4

No files matched your search

-2
View File
@@ -1744,8 +1744,6 @@ class ClosedConTests(unittest.TestCase):
with self.assertRaises(sqlite.ProgrammingError):
con.set_progress_handler(progress, 100)
# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_closed_call(self):
con = sqlite.connect(":memory:")
con.close()
+6 -2
View File
@@ -852,10 +852,14 @@ mod _sqlite {
}
impl Callable for Connection {
type Args = (PyUtf8StrRef,);
type Args = FuncArgs;
fn call(zelf: &Py<Self>, args: Self::Args, vm: &VirtualMachine) -> PyResult {
if let Some(stmt) = Statement::new(zelf, args.0, vm)? {
let _ = zelf.db_lock(vm)?;
let (sql,): (PyUtf8StrRef,) = args.bind(vm)?;
if let Some(stmt) = Statement::new(zelf, sql, vm)? {
Ok(stmt.into_ref(&vm.ctx).into())
} else {
Ok(vm.ctx.none())