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 benjamin.peterson, martin.panter, pitrou, serhiy.storchaka, stutzbach
Date 2016-04-12.13:39:10
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1460468351.16.0.241200715938.issue26720@psf.upfronthosting.co.za>
In-reply-to
Content
I realize there is another problem, and doing tricks with a bytes object won’t help that. BufferedWriter bypasses its own buffer for large writes:

>>> writer = BufferedWriter(Raw())
>>> large = bytearray(10000)
>>> writer.write(large)
10000
>>> written.tobytes()[:10]
b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
>>> large[:5] = b"blaua"
>>> written.tobytes()[:10]
b'blaua\x00\x00\x00\x00\x00'

BufferedWriter is passing a view of the original input through, without any copying. Perhaps the simplest thing is to warn and prevent the user from accessing the buffer after write() returns. I suggested some imperfect ideas in Issue 15994. Maybe I should just close this as a duplicate.
History
Date User Action Args
2016-04-12 13:39:11martin.pantersetrecipients: + martin.panter, pitrou, benjamin.peterson, stutzbach, serhiy.storchaka
2016-04-12 13:39:11martin.pantersetmessageid: <1460468351.16.0.241200715938.issue26720@psf.upfronthosting.co.za>
2016-04-12 13:39:11martin.panterlinkissue26720 messages
2016-04-12 13:39:10martin.pantercreate