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

Function try_int_radix

crates/vm/src/builtins/int.rs:763–781  ·  view source on GitHub ↗
(obj: &PyObject, base: u32, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

761}
762
763fn try_int_radix(obj: &PyObject, base: u32, vm: &VirtualMachine) -> PyResult<BigInt> {
764 match_class!(match obj.to_owned() {
765 string @ PyStr => {
766 let s = string.as_wtf8().trim();
767 bytes_to_int(s.as_bytes(), base, vm.state.int_max_str_digits.load())
768 .map_err(|e| handle_bytes_to_int_err(e, obj, vm))
769 }
770 bytes @ PyBytes => {
771 bytes_to_int(bytes.as_bytes(), base, vm.state.int_max_str_digits.load())
772 .map_err(|e| handle_bytes_to_int_err(e, obj, vm))
773 }
774 bytearray @ PyByteArray => {
775 let inner = bytearray.borrow_buf();
776 bytes_to_int(&inner, base, vm.state.int_max_str_digits.load())
777 .map_err(|e| handle_bytes_to_int_err(e, obj, vm))
778 }
779 _ => Err(vm.new_type_error("int() can't convert non-string with explicit base")),
780 })
781}
782
783// Retrieve inner int value:
784pub(crate) fn get_value(obj: &PyObject) -> &BigInt {

Callers 1

slot_newMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected