From 35247ca8038314fc311dba89593c8a23ea2a938b Mon Sep 17 00:00:00 2001 From: Jiseok CHOI Date: Wed, 9 Jul 2025 15:29:30 +0900 Subject: [PATCH] Fix SQLite large integer overflow error handling --- Lib/test/test_sqlite3/test_userfunctions.py | 2 -- stdlib/src/sqlite.rs | 4 +++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_sqlite3/test_userfunctions.py b/Lib/test/test_sqlite3/test_userfunctions.py index d2925feb0f8..7b092365d4b 100644 --- a/Lib/test/test_sqlite3/test_userfunctions.py +++ b/Lib/test/test_sqlite3/test_userfunctions.py @@ -337,8 +337,6 @@ def test_nan_float(self): # 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, diff --git a/stdlib/src/sqlite.rs b/stdlib/src/sqlite.rs index ed3f7399176..dc7a742b564 100644 --- a/stdlib/src/sqlite.rs +++ b/stdlib/src/sqlite.rs @@ -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::() { - let val = val.try_to_primitive::(vm)?; + let val = val.try_to_primitive::(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::() { let val = val.to_f64();