Skip to content

Commit b5c9b7c

Browse files
committed
add note about read-only buffers
add a note about ffi.from_buffer not respecting read-only buffers
1 parent 795c31a commit b5c9b7c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/pa_ringbuffer.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ class _RingBufferBase(object):
7171
Python thread to another Python thread. For this, the `queue.Queue`
7272
class from the standard library can be used.
7373
74+
Note that if you pass a read-only buffer object, you still get a writable
75+
RingBuffer; it is your responsibility not to write there if the original
76+
buffer doesn’t expect you to.
77+
7478
:param elementsize: The size of a single data element in bytes.
7579
:type elementsize: int
7680
:param size: The number of elements in the buffer (must be a power
@@ -89,7 +93,7 @@ def __init__(self, elementsize, size=None, buffer=None):
8993
"size is required when buffer parameter is not specified")
9094
self._data = self._ffi.new('unsigned char[]', size * elementsize)
9195
elif size is not None:
92-
raise TypeError('exactly one of {size, buffer} is required')
96+
raise TypeError('exactly one of {size, buffer} is required')
9397
else:
9498
try:
9599
data = self._ffi.from_buffer(buffer)

0 commit comments

Comments
 (0)