[issue22003] BytesIO copy-on-write

Stefan Krah report at bugs.python.org
Mon Jul 21 18:04:47 CEST 2014


Stefan Krah added the comment:

I think checking for a readonly view is fine.  The protocol is this:

  1) Use the PyBUF_WRITABLE flag in the request. Then the provider must
     either have a writable buffer or else deny the request entirely.

  2) Omit the PyBUF_WRITABLE flag in the request.  Then the provider can
     return a writable or a readonly buffer, but must set the readonly flag
     correctly AND export the same type of buffer to ALL consumers.

It is not possible to ask for a readonly buffer explicitly, but the
readonly flag in the Py_Buffer struct should always be set correctly.

It is hard to guess the original intention of the PEP-3118 authors, but
in practice "readonly" means "immutable" here.  IMO a buffer provider would
be seriously broken if a readonly buffer is mutated in any way.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22003>
_______________________________________


More information about the Python-bugs-list mailing list