| 703 | } |
| 704 | |
| 705 | fn unpack_pascal(vm: &VirtualMachine, data: &[u8]) -> PyObjectRef { |
| 706 | let (&len, data) = match data.split_first() { |
| 707 | Some(x) => x, |
| 708 | None => { |
| 709 | // cpython throws an internal SystemError here |
| 710 | return vm.ctx.new_bytes(vec![]).into(); |
| 711 | } |
| 712 | }; |
| 713 | let len = core::cmp::min(len as usize, data.len()); |
| 714 | vm.ctx.new_bytes(data[..len].to_vec()).into() |
| 715 | } |
| 716 | |
| 717 | // XXX: are those functions expected to be placed here? |
| 718 | pub fn struct_error_type(vm: &VirtualMachine) -> &'static PyTypeRef { |