[New-bugs-announce] [issue1323] py3k: file.truncate() changes the file position
Amaury Forgeot d'Arc
report at bugs.python.org
Thu Oct 25 00:30:33 CEST 2007
New submission from Amaury Forgeot d'Arc:
This patch corrects a problem in test_file.py on Windows:
f.truncate() seeks to the truncation point, but does not empty the
buffers. In the test, f.tell() returns -1...
Now we flush the file before, and seek to the initial position after.
The same trick was present in 2.5, in fileobject.c::file_truncate. The
same comments apply as well.
Reviewers needed! Flushing may change the behaviour, but seems more
correct to me (and closer to python2.5). Should we add specific tests
Also, change the test to be sure to close the file before trying to
remove it (it seems that in a finally: block, the exception still
references all the local variables in the traceback). Otherwise the
previous problem is hidden by a "file locked" error in the finally block.
title: py3k: file.truncate() changes the file position
versions: Python 3.0
Added file: http://bugs.python.org/file8606/truncate.diff
Tracker <report at bugs.python.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 2111 bytes
Desc: not available
Url : http://mail.python.org/pipermail/new-bugs-announce/attachments/20071024/ec80455c/attachment.obj
More information about the New-bugs-announce