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

Method __instancecheck__

crates/vm/src/builtins/union.rs:131–145  ·  view source on GitHub ↗
(
        zelf: PyRef<Self>,
        obj: PyObjectRef,
        vm: &VirtualMachine,
    )

Source from the content-addressed store, hash-verified

129
130 #[pymethod]
131 fn __instancecheck__(
132 zelf: PyRef<Self>,
133 obj: PyObjectRef,
134 vm: &VirtualMachine,
135 ) -> PyResult<bool> {
136 if zelf
137 .args
138 .iter()
139 .any(|x| x.class().is(vm.ctx.types.generic_alias_type))
140 {
141 Err(vm.new_type_error("isinstance() argument 2 cannot be a parameterized generic"))
142 } else {
143 obj.is_instance(zelf.__args__().as_object(), vm)
144 }
145 }
146
147 #[pymethod]
148 fn __subclasscheck__(

Callers

nothing calls this directly

Calls 7

isMethod · 0.80
is_instanceMethod · 0.80
ErrClass · 0.50
iterMethod · 0.45
classMethod · 0.45
as_objectMethod · 0.45
__args__Method · 0.45

Tested by

no test coverage detected