Message263248
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. |
|
Date |
User |
Action |
Args |
2016-04-12 13:39:11 | martin.panter | set | recipients:
+ martin.panter, pitrou, benjamin.peterson, stutzbach, serhiy.storchaka |
2016-04-12 13:39:11 | martin.panter | set | messageid: <1460468351.16.0.241200715938.issue26720@psf.upfronthosting.co.za> |
2016-04-12 13:39:11 | martin.panter | link | issue26720 messages |
2016-04-12 13:39:10 | martin.panter | create | |
|