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

Method slot_init

crates/vm/src/types/slot.rs:1644–1672  ·  view source on GitHub ↗
(zelf: PyObjectRef, args: FuncArgs, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

1642 #[inline]
1643 #[pyslot]
1644 fn slot_init(zelf: PyObjectRef, args: FuncArgs, vm: &VirtualMachine) -> PyResult<()> {
1645 #[cfg(debug_assertions)]
1646 let class_name_for_debug = zelf.class().name().to_string();
1647
1648 let zelf = match zelf.try_into_value(vm) {
1649 Ok(zelf) => zelf,
1650 Err(err) => {
1651 #[cfg(debug_assertions)]
1652 {
1653 if let Ok(msg) = err.as_object().repr(vm) {
1654 let double_appearance = msg
1655 .to_string_lossy()
1656 .matches(&class_name_for_debug as &str)
1657 .count()
1658 == 2;
1659 if double_appearance {
1660 panic!(
1661 "This type `{}` doesn't seem to support `init`. Override `slot_init` instead: {}",
1662 class_name_for_debug, msg
1663 );
1664 }
1665 }
1666 }
1667 return Err(err);
1668 }
1669 };
1670 let args: Self::Args = args.bind(vm)?;
1671 Self::init(zelf, args, vm)
1672 }
1673
1674 fn init(zelf: PyRef<Self>, args: Self::Args, vm: &VirtualMachine) -> PyResult<()>;
1675}

Callers

nothing calls this directly

Implementers 15

random.rscrates/stdlib/src/random.rs
socket.rscrates/stdlib/src/socket.rs
_asyncio.rscrates/stdlib/src/_asyncio.rs
_sqlite3.rscrates/stdlib/src/_sqlite3.rs
exceptions.rscrates/vm/src/exceptions.rs
exception_group.rscrates/vm/src/exception_group.rs
_io.rscrates/vm/src/stdlib/_io.rs
_collections.rscrates/vm/src/stdlib/_collections.rs
pyast.rscrates/vm/src/stdlib/_ast/pyast.rs
python.rscrates/vm/src/stdlib/_ast/python.rs
union.rscrates/vm/src/stdlib/_ctypes/union.rs
pointer.rscrates/vm/src/stdlib/_ctypes/pointer.r

Calls 12

to_stringMethod · 0.80
try_into_valueMethod · 0.80
ErrClass · 0.50
initFunction · 0.50
nameMethod · 0.45
classMethod · 0.45
reprMethod · 0.45
as_objectMethod · 0.45
countMethod · 0.45
matchesMethod · 0.45
to_string_lossyMethod · 0.45
bindMethod · 0.45

Tested by

no test coverage detected