Martin Panter <vadmium...@gmail.com> added the comment:

This is the same as Issue 26158. Truncating text files is not clearly 
documented for a start, and truncating after reading doesn’t seem to be 
considered much in the implementations.

Your question is answered at <https://bugs.python.org/issue26158#msg258619>. 
Your code calls the C implementation of “io.TextIOWrapper.truncate”. This 
implementation does not consider that there are 8 unread bytes in a buffer, so 
it truncates the file at the end of the buffer (5 read + 8 unread = 13 bytes).

----------
nosy: +martin.panter
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> File truncate() not defaulting to current position as documented

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue35304>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to