10000 Handle usize > usize::MAX case · RustPython/RustPython@6a53ec3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6a53ec3

Browse files
Popproyouknowone
authored andcommitted
Handle usize > usize::MAX case
1 parent c5550cd commit 6a53ec3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

vm/src/stdlib/itertools.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1985,7 +1985,9 @@ mod decl {
19851985
if n.lt(&BigInt::one()) {
19861986
return Err(vm.new_value_error("n must be at least one".to_owned()));
19871987
}
1988-
let n = n.to_usize().unwrap();
1988+
let n = n
1989+
.to_usize()
1990+
.ok_or(vm.new_value_error("Python int too large to convert to usize".to_owned()))?;
19891991
let iterable = iterable_ref.get_iter(vm)?;
19901992

19911993
Self {

0 commit comments

Comments
 (0)
0