MCPcopy Index your code
hub / github.com/RustPython/RustPython / tounicode

Method tounicode

crates/stdlib/src/array.rs:838–847  ·  view source on GitHub ↗
(&self, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

836
837 #[pymethod]
838 fn tounicode(&self, vm: &VirtualMachine) -> PyResult<Wtf8Buf> {
839 let array = self.array.read();
840 if array.typecode() != 'u' {
841 return Err(
842 vm.new_value_error("tounicode() may only be called on unicode type arrays")
843 );
844 }
845 let bytes = array.get_bytes();
846 Self::_wchar_bytes_to_string(bytes, self.itemsize(), vm)
847 }
848
849 fn _from_bytes(&self, b: &[u8], itemsize: usize, vm: &VirtualMachine) -> PyResult<()> {
850 if !b.len().is_multiple_of(itemsize) {

Callers 3

test_bufferMethod · 0.80
test_unicodeMethod · 0.80
repr_strMethod · 0.80

Calls 5

typecodeMethod · 0.80
ErrClass · 0.50
readMethod · 0.45
get_bytesMethod · 0.45
itemsizeMethod · 0.45

Tested by 2

test_bufferMethod · 0.64
test_unicodeMethod · 0.64