Get list items iterator if obj is a list (or subclass), None iterator otherwise
(obj: &PyObjectRef, vm: &VirtualMachine)
| 670 | |
| 671 | /// Get list items iterator if obj is a list (or subclass), None iterator otherwise |
| 672 | fn get_items_iter(obj: &PyObjectRef, vm: &VirtualMachine) -> PyResult<(PyObjectRef, PyObjectRef)> { |
| 673 | let listitems: PyObjectRef = if obj.fast_isinstance(vm.ctx.types.list_type) { |
| 674 | obj.get_iter(vm)?.into() |
| 675 | } else { |
| 676 | vm.ctx.none() |
| 677 | }; |
| 678 | |
| 679 | let dictitems: PyObjectRef = if obj.fast_isinstance(vm.ctx.types.dict_type) { |
| 680 | let items = vm.call_method(obj, "items", ())?; |
| 681 | items.get_iter(vm)?.into() |
| 682 | } else { |
| 683 | vm.ctx.none() |
| 684 | }; |
| 685 | |
| 686 | Ok((listitems, dictitems)) |
| 687 | } |
| 688 | |
| 689 | /// reduce_newobj - creates reduce tuple for protocol >= 2 |
| 690 | fn reduce_newobj(obj: PyObjectRef, vm: &VirtualMachine) -> PyResult { |
no test coverage detected