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

Method py_new

crates/vm/src/builtins/mappingproxy.rs:65–78  ·  view source on GitHub ↗
(_cls: &Py<PyType>, mapping: Self::Args, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

63 type Args = PyObjectRef;
64
65 fn py_new(_cls: &Py<PyType>, mapping: Self::Args, vm: &VirtualMachine) -> PyResult<Self> {
66 if mapping.mapping_unchecked().check()
67 && !mapping.downcastable::<PyList>()
68 && !mapping.downcastable::<PyTuple>()
69 {
70 return Ok(Self {
71 mapping: MappingProxyInner::Mapping(ArgMapping::new(mapping)),
72 });
73 }
74 Err(vm.new_type_error(format!(
75 "mappingproxy() argument must be a mapping, not {}",
76 mapping.class()
77 )))
78 }
79}
80
81#[pyclass(with(

Callers

nothing calls this directly

Calls 5

newFunction · 0.85
mapping_uncheckedMethod · 0.80
MappingClass · 0.50
ErrClass · 0.50
checkMethod · 0.45

Tested by

no test coverage detected