From 2b3b5fbab6275d4652cafab50dad2e3535f54527 Mon Sep 17 00:00:00 2001 From: snowapril Date: Sat, 2 Oct 2021 19:06:44 +0900 Subject: [PATCH] fix pystruct to use struct.error Signed-off-by: snowapril --- vm/src/stdlib/pystruct.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/vm/src/stdlib/pystruct.rs b/vm/src/stdlib/pystruct.rs index 04747d8cf..3dad151f3 100644 --- a/vm/src/stdlib/pystruct.rs +++ b/vm/src/stdlib/pystruct.rs @@ -460,7 +460,9 @@ pub(crate) mod _struct { T: PrimInt + for<'a> std::convert::TryFrom<&'a BigInt>, { match vm.to_index_opt(arg) { - Some(index) => index?.try_to_primitive(vm), + Some(index) => index? + .try_to_primitive(vm) + .map_err(|_| new_struct_error(vm, "argument out of range".to_owned())), None => Err(new_struct_error( vm, "required argument is not an integer".to_owned(),