Helper function to iterate over mapping keys using the keys() method. This ensures proper order preservation for OrderedDict and other custom mappings.
(
vm: &VirtualMachine,
mapping: &PyObject,
func_str: &Wtf8,
mut key_handler: F,
)
| 6525 | /// Helper function to iterate over mapping keys using the keys() method. |
| 6526 | /// This ensures proper order preservation for OrderedDict and other custom mappings. |
| 6527 | fn iterate_mapping_keys<F>( |
| 6528 | vm: &VirtualMachine, |
| 6529 | mapping: &PyObject, |
| 6530 | func_str: &Wtf8, |
| 6531 | mut key_handler: F, |
| 6532 | ) -> PyResult<()> |
| 6533 | where |
| 6534 | F: FnMut(PyObjectRef) -> PyResult<()>, |
| 6535 | { |
| 6536 | let Some(keys_method) = vm.get_method(mapping.to_owned(), vm.ctx.intern_str("keys")) else { |
| 6537 | return Err(vm.new_type_error(format!( |
| 6538 | "{} argument after ** must be a mapping, not {}", |
| 6539 | func_str, |
| 6540 | mapping.class().name() |
| 6541 | ))); |
| 6542 | }; |
| 6543 | |
| 6544 | let keys = keys_method?.call((), vm)?.get_iter(vm)?; |
| 6545 | while let PyIterReturn::Return(key) = keys.next(vm)? { |
| 6546 | key_handler(key)?; |
| 6547 | } |
| 6548 | Ok(()) |
| 6549 | } |
| 6550 | |
| 6551 | /// Vectorcall dispatch for Instruction::Call (positional args only). |
| 6552 | /// Uses vectorcall slot if available, otherwise falls back to FuncArgs. |
nothing calls this directly
no test coverage detected