(zelf: PyTypeRef, args: FuncArgs, vm: &VirtualMachine)
| 81 | type Args = OptionalArg<PyObjectRef>; |
| 82 | |
| 83 | fn slot_new(zelf: PyTypeRef, args: FuncArgs, vm: &VirtualMachine) -> PyResult { |
| 84 | let x: Self::Args = args.bind(vm)?; |
| 85 | if !zelf.fast_isinstance(vm.ctx.types.type_type) { |
| 86 | let actual_class = zelf.class(); |
| 87 | let actual_type = &actual_class.name(); |
| 88 | return Err(vm.new_type_error(format!( |
| 89 | "requires a 'type' object but received a '{actual_type}'" |
| 90 | ))); |
| 91 | } |
| 92 | let val = x.map_or(Ok(false), |val| val.try_to_bool(vm))?; |
| 93 | Ok(vm.ctx.new_bool(val).into()) |
| 94 | } |
| 95 | |
| 96 | fn py_new(_cls: &Py<PyType>, _args: Self::Args, _vm: &VirtualMachine) -> PyResult<Self> { |
| 97 | unimplemented!("use slot_new") |
nothing calls this directly
no test coverage detected