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 liugang93, martin.panter
Date 2018-11-24.01:11:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1543021867.06.0.788709270274.issue35304@psf.upfronthosting.co.za>
In-reply-to
Content
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).
History
Date User Action Args
2018-11-24 01:11:07martin.pantersetrecipients: + martin.panter, liugang93
2018-11-24 01:11:07martin.pantersetmessageid: <1543021867.06.0.788709270274.issue35304@psf.upfronthosting.co.za>
2018-11-24 01:11:06martin.panterlinkissue35304 messages
2018-11-24 01:11:05martin.pantercreate