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: io.BytesIO doesn't support the buffer protocol
Type: enhancement Stage: resolved
Components: IO, Library (Lib) Versions: Python 3.2
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, benjamin.peterson, georg.brandl, pitrou
Priority: normal Keywords: patch

Created on 2009-03-18 10:40 by pitrou, last changed 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit
bytesiobuf2.patch pitrou, 2010-09-03 17:53
Messages (7)
msg83740 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-03-18 10:40
It may be logical for BytesIO to support the buffer protocol (readable
/and/ writable).
msg85504 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-04-05 14:41
Is this still unimplemented?
msg85507 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-04-05 14:52
I don't remember which use case I was thinking about when I suggested
this, but it may be useful to e.g. write() all the data to a file object
without actually making a copy (getvalue() does).
msg115304 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-09-01 14:48
Thinking about it, I'm not sure this would be a good idea to do this by default. There is an ambiguity where it's not obvious if the buffer would contain the whole data or only the bytes after the current position.

I think perhaps an explicit method (getbuffer()?) could be used to export a buffer-compatible object, without copying. Perhaps a memoryview; this would imply defining bf_releasebuffer without bf_getbuffer.
msg115476 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-09-03 17:49
Here is a patch implementing getbuffer(), together with tests.
msg115479 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-09-03 17:53
There was an unused "weakreflist" member.
msg115728 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-09-06 18:50
This was committed in r84562.
Date User Action Args
2022-04-11 14:56:46adminsetgithub: 49756
2010-09-06 18:50:12pitrousetstatus: open -> closed
resolution: fixed
messages: + msg115728

stage: patch review -> resolved
2010-09-03 17:53:48pitrousetnosy: + amaury.forgeotdarc, benjamin.peterson
components: + IO
2010-09-03 17:53:33pitrousetfiles: - bytesiobuf2.patch
2010-09-03 17:53:24pitrousetfiles: + bytesiobuf2.patch

messages: + msg115479
2010-09-03 17:49:12pitrousetfiles: + bytesiobuf2.patch
keywords: + patch
messages: + msg115476

stage: needs patch -> patch review
2010-09-01 14:48:06pitrousetmessages: + msg115304
stage: test needed -> needs patch
2010-08-09 03:55:35terry.reedysetversions: + Python 3.2, - Python 3.1
2009-04-05 14:52:09pitrousetmessages: + msg85507
2009-04-05 14:41:01georg.brandlsetnosy: + georg.brandl
messages: + msg85504
2009-03-18 10:40:11pitroucreate