Fix SQLite large integer overflow error handling (#5916)

This commit is contained in:
Jiseok CHOI
2025-07-09 17:14:45 +09:00
committed by GitHub
parent c195473a29
commit 341341520e
2 changed files with 3 additions and 3 deletions

View File

@@ -337,8 +337,6 @@ class FunctionTests(unittest.TestCase):
# SQLite has no concept of nan; it is converted to NULL
self.assertTrue(cur.fetchone()[0])
# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_too_large_int(self):
err = "Python int too large to convert to SQLite INTEGER"
self.assertRaisesRegex(OverflowError, err, self.con.execute,

View File

@@ -2609,7 +2609,9 @@ mod _sqlite {
let ret = if vm.is_none(obj) {
unsafe { sqlite3_bind_null(self.st, pos) }
} else if let Some(val) = obj.payload::<PyInt>() {
let val = val.try_to_primitive::<i64>(vm)?;
let val = val.try_to_primitive::<i64>(vm).map_err(|_| {
vm.new_overflow_error("Python int too large to convert to SQLite INTEGER")
})?;
unsafe { sqlite3_bind_int64(self.st, pos, val) }
} else if let Some(val) = obj.payload::<PyFloat>() {
let val = val.to_f64();