classification
Title: Initial bytes to BytesIO cannot be seeked to
Type: behavior Stage: resolved
Components: IO Versions: Python 3.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Samuli G, serhiy.storchaka
Priority: normal Keywords:

Created on 2017-04-07 07:40 by Samuli G, last changed 2017-04-07 07:55 by serhiy.storchaka. This issue is now closed.

Files
File name Uploaded Description Edit
bytesio_bug.py Samuli G, 2017-04-07 07:40 An example exhibiting the bug on Python 3.6.0
Messages (2)
msg291254 - (view) Author: Samuli G (Samuli G) Date: 2017-04-07 07:40
The initial bytes provided for the BytesIO constructor are lost when the stream is written to.

Seeking to offset zero, and then getting the value of the entire buffer results of getting only the bytes that have been appended by calling "write".
msg291255 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-04-07 07:55
This is expected behavior. When you write to ByitesIO you overwrites the old content.

If you want to append to ByitesIO, first move the position to the end: b.seek(0, io.SEEK_END).
History
Date User Action Args
2017-04-07 07:55:10serhiy.storchakasetstatus: open -> closed

nosy: + serhiy.storchaka
messages: + msg291255

resolution: not a bug
stage: resolved
2017-04-07 07:40:16Samuli Gcreate