Skip to content

Commit 21d549c

Browse files
authored
Handle chr() range checks without Rust integer overflow (#7422)
1 parent ed032d3 commit 21d549c

File tree

2 files changed

+1
-2
lines changed

2 files changed

+1
-2
lines changed

Lib/test/test_builtin.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,6 @@ class C3(C2): pass
367367
c3 = C3()
368368
self.assertTrue(callable(c3))
369369

370-
@unittest.expectedFailure # TODO: RUSTPYTHON; OverflowError: Python int too large to convert to Rust isize
371370
def test_chr(self):
372371
self.assertEqual(chr(0), '\0')
373372
self.assertEqual(chr(32), ' ')

crates/vm/src/stdlib/builtins.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ mod builtins {
8888
#[pyfunction]
8989
fn chr(i: PyIntRef, vm: &VirtualMachine) -> PyResult<CodePoint> {
9090
let value = i
91-
.try_to_primitive::<isize>(vm)?
91+
.as_bigint()
9292
.to_u32()
9393
.and_then(CodePoint::from_u32)
9494
.ok_or_else(|| vm.new_value_error("chr() arg not in range(0x110000)"))?;

0 commit comments

Comments
 (0)