(_cls: &Py<PyType>, args: Self::Args, vm: &VirtualMachine)
| 394 | type Args = FuncArgs; |
| 395 | |
| 396 | fn py_new(_cls: &Py<PyType>, args: Self::Args, vm: &VirtualMachine) -> PyResult<Self> { |
| 397 | let n_attr = args.args.len(); |
| 398 | // Check we get no keyword and at least one positional. |
| 399 | if !args.kwargs.is_empty() { |
| 400 | return Err(vm.new_type_error("attrgetter() takes no keyword arguments")); |
| 401 | } |
| 402 | if n_attr == 0 { |
| 403 | return Err(vm.new_type_error("attrgetter expected 1 argument, got 0.")); |
| 404 | } |
| 405 | let mut attrs = Vec::with_capacity(n_attr); |
| 406 | for o in args.args { |
| 407 | if let Ok(r) = o.try_into_value(vm) { |
| 408 | attrs.push(r); |
| 409 | } else { |
| 410 | return Err(vm.new_type_error("attribute name must be a string")); |
| 411 | } |
| 412 | } |
| 413 | Ok(Self { attrs }) |
| 414 | } |
| 415 | } |
| 416 | |
| 417 | impl Callable for PyAttrGetter { |
nothing calls this directly
no test coverage detected