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

Method getbuffer

crates/vm/src/stdlib/_io.rs:4795–4807  ·  view source on GitHub ↗
(self, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

4793 impl PyRef<BytesIO> {
4794 #[pymethod]
4795 fn getbuffer(self, vm: &VirtualMachine) -> PyResult<PyMemoryView> {
4796 if self.closed.load() {
4797 return Err(vm.new_value_error("I/O operation on closed file."));
4798 }
4799 let len = self.buffer.read().cursor.get_ref().len();
4800 let buffer = PyBuffer::new(
4801 self.into(),
4802 BufferDescriptor::simple(len, false),
4803 &BYTES_IO_BUFFER_METHODS,
4804 );
4805 let view = PyMemoryView::from_buffer(buffer, vm)?;
4806 Ok(view)
4807 }
4808 }
4809
4810 static BYTES_IO_BUFFER_METHODS: BufferMethods = BufferMethods {

Callers

nothing calls this directly

Calls 7

newFunction · 0.85
simpleFunction · 0.85
get_refMethod · 0.80
ErrClass · 0.50
loadMethod · 0.45
lenMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected