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

Skip to content
Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c98958e

Browse files
committed
Handle usize > usize::MAX case
1 parent adafea1 commit c98958e

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