Message330368
| 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:07 | martin.panter | set | recipients:
+ martin.panter, liugang93 |
| 2018年11月24日 01:11:07 | martin.panter | set | messageid: <1543021867.06.0.788709270274.issue35304@psf.upfronthosting.co.za> |
| 2018年11月24日 01:11:06 | martin.panter | link | issue35304 messages |
| 2018年11月24日 01:11:05 | martin.panter | create |
|