Skip to content

Commit 3413415

Browse files
authored
Fix SQLite large integer overflow error handling (#5916)
1 parent c195473 commit 3413415

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Lib/test/test_sqlite3/test_userfunctions.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,6 @@ def test_nan_float(self):
337337
# SQLite has no concept of nan; it is converted to NULL
338338
self.assertTrue(cur.fetchone()[0])
339339

340-
# TODO: RUSTPYTHON
341-
@unittest.expectedFailure
342340
def test_too_large_int(self):
343341
err = "Python int too large to convert to SQLite INTEGER"
344342
self.assertRaisesRegex(OverflowError, err, self.con.execute,

stdlib/src/sqlite.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2609,7 +2609,9 @@ mod _sqlite {
26092609
let ret = if vm.is_none(obj) {
26102610
unsafe { sqlite3_bind_null(self.st, pos) }
26112611
} else if let Some(val) = obj.payload::<PyInt>() {
2612-
let val = val.try_to_primitive::<i64>(vm)?;
2612+
let val = val.try_to_primitive::<i64>(vm).map_err(|_| {
2613+
vm.new_overflow_error("Python int too large to convert to SQLite INTEGER")
2614+
})?;
26132615
unsafe { sqlite3_bind_int64(self.st, pos, val) }
26142616
} else if let Some(val) = obj.payload::<PyFloat>() {
26152617
let val = val.to_f64();

0 commit comments

Comments
 (0)