[issue35304] The return of truncate(size=None) (file io) is unexpected
Martin Panter
report at bugs.python.org
Fri Nov 23 20:11:07 EST 2018
Martin Panter <vadmium+py at 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 <report at bugs.python.org>
<https://bugs.python.org/issue35304>
_______________________________________
More information about the Python-bugs-list
mailing list