Issue 1323: py3k: file.truncate() changes the file position
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 for this? 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.