From 1e6da5f430cf560ffa2286e8d34037025df1b8a7 Mon Sep 17 00:00:00 2001 From: Jiseok CHOI Date: Wed, 30 Jul 2025 14:05:17 +0900 Subject: [PATCH] sqlite: Align Connection.__call__ error handling with CPython (#6042) --- 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 b123786db..7a16f7565 100644 --- a/Lib/test/test_sqlite3/test_dbapi.py +++ b/Lib/test/test_sqlite3/test_dbapi.py @@ -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() diff --git a/stdlib/src/sqlite.rs b/stdlib/src/sqlite.rs index 0ee3f43f1..964da64bc 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())