Skip to content

Commit 4b4e56f

Browse files
committed
sqlite3: reject negative fetchmany values
1 parent 4c25370 commit 4b4e56f

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

Lib/test/test_sqlite3/test_dbapi.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,6 @@ def test_fetchmany(self):
11261126
res = self.cu.fetchmany(100)
11271127
self.assertEqual(res, [])
11281128

1129-
@unittest.expectedFailure # TODO: RUSTPYTHON fetchmany size validation not implemented
11301129
def test_invalid_fetchmany(self):
11311130
UINT32_MAX = (1 << 32) - 1
11321131
fetchmany = self.cu.fetchmany

crates/stdlib/src/_sqlite3.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1883,9 +1883,16 @@ mod _sqlite3 {
18831883
args: FetchManyArgs,
18841884
vm: &VirtualMachine,
18851885
) -> PyResult<Vec<PyObjectRef>> {
1886-
let max_rows = args
1887-
.size
1888-
.unwrap_or_else(|| zelf.arraysize.load(Ordering::Relaxed));
1886+
let max_rows = match args.size {
1887+
Some(size) => {
1888+
if size < 0 {
1889+
return Err(vm.new_value_error("fetchmany many not be negative"));
1890+
}
1891+
1892+
size
1893+
}
1894+
None => zelf.arraysize.load(Ordering::Relaxed),
1895+
};
18891896

18901897
let mut list = vec![];
18911898
while let PyIterReturn::Return(row) = Cursor::next(zelf, vm)? {

0 commit comments

Comments
 (0)