New submission from liugang <[email protected]>:
-- run in Windows 10
1 -
f = open('test', "w+")
f.write('xxx\nyyy\nzzz')
f.seek(0)
f.readline()
print(f.tell()) # output 5 (xxx\r\n)
x = f.truncate()
print(x) # output 13 (xxx\r\nyyy\r\nzzz), why it is 13, not 5?
2 -
f = open('test', "w+")
f.write('xxx\nyyy\nzzz')
f.seek(0)
f.readline()
print(f.tell()) # output 5 (xxx\r\n)
f.seek(f.tell())
x = f.truncate()
print(x) # output 5
----------
components: IO
messages: 330357
nosy: liugang93
priority: normal
severity: normal
status: open
title: The return of truncate(size=None) (file io) is unexpected
type: behavior
versions: Python 3.5
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue35304>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com