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

Function handle_bytes_to_int_err

crates/vm/src/protocol/number.rs:733–753  ·  view source on GitHub ↗
(
    e: BytesToIntError,
    obj: &PyObject,
    vm: &VirtualMachine,
)

Source from the content-addressed store, hash-verified

731}
732
733pub fn handle_bytes_to_int_err(
734 e: BytesToIntError,
735 obj: &PyObject,
736 vm: &VirtualMachine,
737) -> PyBaseExceptionRef {
738 match e {
739 BytesToIntError::InvalidLiteral { base } => vm.new_value_error(format!(
740 "invalid literal for int() with base {base}: {}",
741 match obj.repr(vm) {
742 Ok(v) => v,
743 Err(err) => return err,
744 },
745 )),
746 BytesToIntError::InvalidBase => {
747 vm.new_value_error("int() base must be >= 2 and <= 36, or 0")
748 }
749 BytesToIntError::DigitLimit { got, limit } => vm.new_value_error(format!(
750"Exceeds the limit ({limit} digits) for integer string conversion: value has {got} digits; use sys.set_int_max_str_digits() to increase the limit"
751 )),
752 }
753}

Callers 1

try_convertMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected