[issue35304] The return of truncate(size=None) (file io) is unexpected
liugang
report at bugs.python.org
Fri Nov 23 14:44:37 EST 2018
liugang <liugang93 at 163.com> added the comment:
# Run in Windows 10
# Code snippet 1
f = open('test', "w+")
f.write('xxx\nyyy\nzzz')
f.seek(0)
f.readline()
print(f.tell()) # 5
x = f.truncate()
print(x) # 13 - why it is 13, not 5?
# Code snippet 2
f = open('test', "w+")
f.write('xxx\nyyy\nzzz')
f.seek(0)
f.readline()
print(f.tell()) # 5
f.seek(f.tell())
x = f.truncate()
print(x) # 5
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35304>
_______________________________________
More information about the Python-bugs-list
mailing list