Skip to content

Commit 1e6da5f

Browse files
authored
sqlite: Align Connection.__call__ error handling with CPython (#6042)
1 parent cee579e commit 1e6da5f

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

Lib/test/test_sqlite3/test_dbapi.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1744,8 +1744,6 @@ def progress(): pass
17441744
with self.assertRaises(sqlite.ProgrammingError):
17451745
con.set_progress_handler(progress, 100)
17461746

1747-
# TODO: RUSTPYTHON
1748-
@unittest.expectedFailure
17491747
def test_closed_call(self):
17501748
con = sqlite.connect(":memory:")
17511749
con.close()

stdlib/src/sqlite.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -852,10 +852,14 @@ mod _sqlite {
852852
}
853853

854854
impl Callable for Connection {
855-
type Args = (PyUtf8StrRef,);
855+
type Args = FuncArgs;
856856

857857
fn call(zelf: &Py<Self>, args: Self::Args, vm: &VirtualMachine) -> PyResult {
858-
if let Some(stmt) = Statement::new(zelf, args.0, vm)? {
858+
let _ = zelf.db_lock(vm)?;
859+
860+
let (sql,): (PyUtf8StrRef,) = args.bind(vm)?;
861+
862+
if let Some(stmt) = Statement::new(zelf, sql, vm)? {
859863
Ok(stmt.into_ref(&vm.ctx).into())
860864
} else {
861865
Ok(vm.ctx.none())

0 commit comments

Comments
 (0)