This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Using a read-only buffer.
Type: enhancement Stage:
Components: ctypes Versions: Python 3.7
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: jakirkham, martin.panter, mrolle
Priority: normal Keywords:

Created on 2016-11-09 04:04 by mrolle, last changed 2022-04-11 14:58 by admin.

Messages (2)
msg280375 - (view) Author: Michael Rolle (mrolle) Date: 2016-11-09 04:04
Suggest that the _CData.from_buffer (source) method allow a read-only
source as an argument, in which case any assignments to
the object would raise some type of exception.
If the source is shared with some writable object,
then changes to said object would be reflected in the
_CData object.  If this behavior is not what you want,
then you could just make a new method called, say,
from_buffer_shared (source).
msg280717 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-11-13 21:09
Issue 11427 has some discussion about this. It seems one concern was to make it hard to modify the buffer of a bytes object (which is supposed to be immutable). But I agree there should be an easy way to access read-only buffers in ctypes. Perhaps that could be by relaxing from_buffer(), or perhaps by some safer or more explicit API.

See also Issue 11429, complaining about scattered support of writable buffers elsewhere, and using bytes objects with an offset.
Date User Action Args
2022-04-11 14:58:39adminsetgithub: 72832
2021-08-18 00:51:09jakirkhamsetnosy: + jakirkham
2016-11-13 21:09:46martin.pantersetnosy: + martin.panter

messages: + msg280717
versions: + Python 3.7
2016-11-09 04:04:52mrollecreate