mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
Handle chr() range checks without Rust integer overflow (#7422)
This commit is contained in:
1 parent
3106c30d58
commit
ae73aab6a4
2 files changed
+1
-2
No files matched your search
Vendored
-1
@@ -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), ' ')
|
||||
|
||||
@@ -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)"))?;
|
||||
|
||||
Reference in new issue
Block a user