The patch fixes for real what "Patch # 1323 by Amaury Forgeot d'Arc" claims to have fixed. I reverted his patch to io.py and implemented the fix in the Windows specific part of truncate in _fileio.c. It fixes two tests for raw io on Windows.
While I like fixing the position restore in _fileio.c, I also liked Amaury's flush() call in _BufferedIOMixin. Perhaps you can keep that part (while losing the position restore)?
> While I like fixing the position restore in _fileio.c, I also liked > Amaury's flush() call in _BufferedIOMixin. Perhaps you can keep that > part (while losing the position restore)? Good point. We have to call flush() in _BufferedIOMixin as you said. I checked if I could add a flush call to _fileio but it makes no sense. We are working on file descriptors which means we don't have to use fflush() and FileIO's flush() is a NOOP.
Committed revision 58673. I made one change, hopefully I didn't screw it up: skip the positional restore if the truncation itself failed. Otherwise the positional restore might overwrite the error from the truncation. After an error from this function they shouldn't make any assumptions about the position anyway!