[issue26158] File truncate() not defaulting to current position as documented

Serhiy Storchaka report at bugs.python.org
Tue Jan 19 13:04:26 EST 2016


Serhiy Storchaka added the comment:

This is not always possible. Consider following example:

>>> open('temp.txt', 'wb').write(b'+BDAEMQQyBDMENA-')
16
>>> f = open('temp.txt', 'r+', encoding='utf-7')
>>> f.read(2)
'аб'

What should be the result of truncating?

I think it would be better to not implement truncate() for text files at all.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26158>
_______________________________________


More information about the Python-bugs-list mailing list