Parse hex string from str or bytes-like object
(string: PyObjectRef, vm: &VirtualMachine)
| 483 | |
| 484 | /// Parse hex string from str or bytes-like object |
| 485 | pub fn fromhex_object(string: PyObjectRef, vm: &VirtualMachine) -> PyResult<Vec<u8>> { |
| 486 | if let Some(s) = string.downcast_ref::<PyStr>() { |
| 487 | Self::fromhex(s.as_bytes(), vm) |
| 488 | } else if let Ok(buffer) = PyBuffer::try_from_borrowed_object(vm, &string) { |
| 489 | let borrowed = buffer |
| 490 | .as_contiguous() |
| 491 | .ok_or_else(|| vm.new_buffer_error("fromhex() requires a contiguous buffer"))?; |
| 492 | Self::fromhex(&borrowed, vm) |
| 493 | } else { |
| 494 | Err(vm.new_type_error(format!( |
| 495 | "fromhex() argument must be str or bytes-like, not {}", |
| 496 | string.class().name() |
| 497 | ))) |
| 498 | } |
| 499 | } |
| 500 | |
| 501 | #[inline] |
| 502 | fn _pad( |
nothing calls this directly
no test coverage detected