From e632da42be5d43a70204223faf1850be29be590c Mon Sep 17 00:00:00 2001 From: Jiseok CHOI Date: Mon, 28 Jul 2025 18:08:14 +0900 Subject: [PATCH] sqlite: Align Connection.__call__ error handling with CPython --- Lib/test/test_sqlite3/test_dbapi.py | 2 -- stdlib/src/sqlite.rs | 8 ++++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_sqlite3/test_dbapi.py b/Lib/test/test_sqlite3/test_dbapi.py index b123786db0..7a16f75655 100644 --- a/Lib/test/test_sqlite3/test_dbapi.py +++ b/Lib/test/test_sqlite3/test_dbapi.py @@ -1744,8 +1744,6 @@ def progress(): pass 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() diff --git a/stdlib/src/sqlite.rs b/stdlib/src/sqlite.rs index 0ee3f43f17..964da64bcf 100644 --- a/stdlib/src/sqlite.rs +++ b/stdlib/src/sqlite.rs @@ -852,10 +852,14 @@ mod _sqlite { } impl Callable for Connection { - type Args = (PyUtf8StrRef,); + type Args = FuncArgs; fn call(zelf: &Py, 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())