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

Method try_convert

crates/vm/src/protocol/number.rs:48–55  ·  view source on GitHub ↗
(obj: &PyObject, lit: &[u8], vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

46
47 pub fn try_int(&self, vm: &VirtualMachine) -> PyResult<PyIntRef> {
48 fn try_convert(obj: &PyObject, lit: &[u8], vm: &VirtualMachine) -> PyResult<PyIntRef> {
49 let base = 10;
50 let digit_limit = vm.state.int_max_str_digits.load();
51
52 let i = bytes_to_int(lit, base, digit_limit)
53 .map_err(|e| handle_bytes_to_int_err(e, obj, vm))?;
54 Ok(PyInt::from(i).into_ref(&vm.ctx))
55 }
56
57 if let Some(i) = self.downcast_ref_if_exact::<PyInt>(vm) {
58 Ok(i.to_owned())

Callers

nothing calls this directly

Calls 4

bytes_to_intFunction · 0.85
handle_bytes_to_int_errFunction · 0.85
loadMethod · 0.45
into_refMethod · 0.45

Tested by

no test coverage detected