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.

Author martin.panter
Recipients martin.panter
Date 2014-12-22.11:41:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1419248477.31.0.512702147737.issue23099@psf.upfronthosting.co.za>
In-reply-to
Content
IOBase.close() doc says file operations raise ValueError, but it is not obvious to me that reading back the “file” buffer is a file operation.

>>> with BytesIO() as b:
...     b.write(b"123")
... 
3
>>> b.getvalue()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: I/O operation on closed file.

Even worse, the memoryview gets corrupted on close():

>>> b = BytesIO(b"123")
>>> m = b.getbuffer()
>>> b.close()
>>> bytes(m)
b'\x98\x02>'

I also noticed that in the “io” implementation, writing to the file seems to be completely disallowed, even if it would not seem to change the size:

>>> b = BytesIO(b"123")
>>> m = b.getbuffer()
>>> b.write(b"x")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
BufferError: Existing exports of data: object cannot be re-sized
History
Date User Action Args
2014-12-22 11:41:17martin.pantersetrecipients: + martin.panter
2014-12-22 11:41:17martin.pantersetmessageid: <1419248477.31.0.512702147737.issue23099@psf.upfronthosting.co.za>
2014-12-22 11:41:17martin.panterlinkissue23099 messages
2014-12-22 11:41:16martin.pantercreate