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

Method py_new

crates/vm/src/builtins/genericalias.rs:61–72  ·  view source on GitHub ↗
(_cls: &Py<PyType>, args: Self::Args, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

59 type Args = FuncArgs;
60
61 fn py_new(_cls: &Py<PyType>, args: Self::Args, vm: &VirtualMachine) -> PyResult<Self> {
62 if !args.kwargs.is_empty() {
63 return Err(vm.new_type_error("GenericAlias() takes no keyword arguments"));
64 }
65 let (origin, arguments): (PyObjectRef, PyObjectRef) = args.bind(vm)?;
66 let args = if let Ok(tuple) = arguments.try_to_ref::<PyTuple>(vm) {
67 tuple.to_owned()
68 } else {
69 PyTuple::new_ref(vec![arguments], &vm.ctx)
70 };
71 Ok(Self::new(origin, args, false, vm))
72 }
73}
74
75#[pyclass(

Callers

nothing calls this directly

Calls 5

newFunction · 0.85
ErrClass · 0.50
is_emptyMethod · 0.45
bindMethod · 0.45
to_ownedMethod · 0.45

Tested by

no test coverage detected