[docs] [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-')
>>> 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>

More information about the docs mailing list