Skip to content

Commit 7a03188

Browse files
committed
sqlite: Align Connection.__call__ error handling with CPython
1 parent d8f1d18 commit 7a03188

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

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
@@ -851,10 +851,14 @@ mod _sqlite {
851851
}
852852

853853
impl Callable for Connection {
854-
type Args = (PyStrRef,);
854+
type Args = FuncArgs;
855855

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

0 commit comments

Comments
 (0)