Handle chr() range checks without Rust integer overflow (#7422)

This commit is contained in:
Lee Dogeon authored and GitHub committed 2026-03-14 15:47:45 +09:00
1 parent 3106c30d58
commit ae73aab6a4
2 files changed
+1 -2

No files matched your search

-1
View File
@@ -367,7 +367,6 @@ class BuiltinTest(ComplexesAreIdenticalMixin, unittest.TestCase):
c3 = C3()
self.assertTrue(callable(c3))
@unittest.expectedFailure # TODO: RUSTPYTHON; OverflowError: Python int too large to convert to Rust isize
def test_chr(self):
self.assertEqual(chr(0), '\0')
self.assertEqual(chr(32), ' ')
+1 -1
View File
@@ -88,7 +88,7 @@ mod builtins {
#[pyfunction]
fn chr(i: PyIntRef, vm: &VirtualMachine) -> PyResult<CodePoint> {
let value = i
.try_to_primitive::<isize>(vm)?
.as_bigint()
.to_u32()
.and_then(CodePoint::from_u32)
.ok_or_else(|| vm.new_value_error("chr() arg not in range(0x110000)"))?;