(obj: PyObjectRef, vm: &VirtualMachine)
| 148 | } |
| 149 | |
| 150 | fn repr_arg(obj: PyObjectRef, vm: &VirtualMachine) -> PyResult<String> { |
| 151 | // ParamSpec args can be lists - format their items with repr_item |
| 152 | if obj.class().is(vm.ctx.types.list_type) { |
| 153 | let list = obj.downcast_ref::<crate::builtins::PyList>().unwrap(); |
| 154 | let len = list.borrow_vec().len(); |
| 155 | let mut parts = Vec::with_capacity(len); |
| 156 | // Use indexed access so list mutation during repr causes IndexError |
| 157 | for i in 0..len { |
| 158 | let item = list |
| 159 | .borrow_vec() |
| 160 | .get(i) |
| 161 | .cloned() |
| 162 | .ok_or_else(|| vm.new_index_error("list index out of range"))?; |
| 163 | parts.push(repr_item(item, vm)?); |
| 164 | } |
| 165 | Ok(format!("[{}]", parts.join(", "))) |
| 166 | } else { |
| 167 | repr_item(obj, vm) |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | let repr_str = format!( |
| 172 | "{}[{}]", |
nothing calls this directly
no test coverage detected