forked from Rust-related/RustPython
Add proper error message for negative length
This commit is contained in:
@@ -640,6 +640,9 @@ impl PyInt {
|
||||
return Err(vm.new_overflow_error("can't convert negative int to unsigned".to_owned()));
|
||||
}
|
||||
|
||||
if args.length.value.sign() == Sign::Minus {
|
||||
return Err(vm.new_value_error("length argument must be non-negative".to_owned()));
|
||||
}
|
||||
let byte_len = args.length.try_to_primitive(vm)?;
|
||||
|
||||
let mut origin_bytes = match (args.byteorder.as_str(), signed) {
|
||||
|
||||
Reference in New Issue
Block a user