MCPcopy Index your code
hub / github.com/RustPython/RustPython / check_repeat_or_overflow_error

Method check_repeat_or_overflow_error

crates/vm/src/vm/vm_ops.rs:158–169  ·  view source on GitHub ↗

Checks that the multiplication is able to be performed. On Ok returns the index as a usize for sequences to be able to use immediately.

(&self, length: usize, n: isize)

Source from the content-addressed store, hash-verified

156 /// Checks that the multiplication is able to be performed. On Ok returns the
157 /// index as a usize for sequences to be able to use immediately.
158 pub fn check_repeat_or_overflow_error(&self, length: usize, n: isize) -> PyResult<usize> {
159 if n <= 0 {
160 Ok(0)
161 } else {
162 let n = n as usize;
163 if length > crate::stdlib::sys::MAXSIZE as usize / n {
164 Err(self.new_overflow_error("repeated value are too long"))
165 } else {
166 Ok(n)
167 }
168 }
169 }
170
171 /// Calling scheme used for binary operations:
172 ///

Callers 4

fromfileMethod · 0.80
mulMethod · 0.80
imulMethod · 0.80
_mulMethod · 0.80

Calls 1

ErrClass · 0.50

Tested by

no test coverage detected