Skip to content

Commit 9d443bb

Browse files
qingshi163youknowone
authored andcommitted
fix range raise overflow error for isize
1 parent 8cdbd18 commit 9d443bb

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

vm/src/builtins/range.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,9 @@ impl PyRange {
380380

381381
impl PyRange {
382382
fn protocol_length(&self, vm: &VirtualMachine) -> PyResult<usize> {
383-
PyInt::from(self.len()).try_to_primitive(vm)
383+
PyInt::from(self.len())
384+
.try_to_primitive::<isize>(vm)
385+
.map(|x| x as usize)
384386
}
385387

386388
const MAPPING_METHODS: PyMappingMethods = PyMappingMethods {

0 commit comments

Comments
 (0)