Message18087
Logged In: YES
user_id=31435
Oh, fudge. The Windows code here is trying very hard to
preserve the file position, but it turns out that C fflush() on
Windows changes the file position in this specific test case.
However, the C standard says (about fflush):
"""
If stream points to an output stream or an update stream in
which the most recent operation was not input, the fflush
function causes any unwritten data for that stream to be
delivered to the host environment to be written to the file;
otherwise, the behavior is undefined.
"""
The last operation performed by the test program before
Python's internals call fflush() was an input operation, so the
effect of calling fflush() is undefined. If it varies across
platforms (as appears to be the case here), that's fine by the
standard, and Python is relying on undefined behavior.
If you stick, e.g., f.seek(5) after the f.tell() call, then on
Windows this test program works as intended (prints 5 at the
end, and the file is truncated to 5 bytes). Then the last
operation performed on the stream opened for update is
*not* an input operation, so the effect of fflush() is defined. |
|
Date |
User |
Action |
Args |
2007-08-23 14:16:41 | admin | link | issue801631 messages |
2007-08-23 14:16:41 | admin | create | |
|