Skip to content

Commit

Permalink
fix: Fix implementation of MPI.buffer.toreadonly()
Browse files Browse the repository at this point in the history
  • Loading branch information
dalcinl committed Jan 15, 2024
1 parent fb35912 commit 693b844
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/mpi4py/MPI/asbuffer.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,12 @@ cdef class buffer:

def toreadonly(self) -> buffer:
"""Return a readonly version of the buffer object."""
cdef void *addr = self.view.buf
cdef Py_ssize_t size = self.view.len
cdef object obj = self
if self.view.obj != NULL:
obj = <object>self.view.obj
cdef buffer buf = <buffer>New(buffer)
PyBuffer_FillInfo(&buf.view, obj,
addr, size, 1, PyBUF_SIMPLE)
PyMPI_GetBuffer(obj, &buf.view, PyBUF_SIMPLE)
buf.view.readonly = 1
return buf

def release(self) -> None:
Expand Down

0 comments on commit 693b844

Please sign in to comment.