This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: File Read/Write Flushing Patch
Type: Stage:
Components: Windows Versions:
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, jurojin
Priority: normal Keywords: patch

Created on 2007-01-16 15:33 by jurojin, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg61060 - (view) Author: jurojin (jurojin) Date: 2007-01-16 15:33
The other night i was watching a google techtalk about python 3000 and
Guido mentioned some problems with the C standard io library.

In particular he highlighted an issue with switching between reading
and writing without flushing and the fact that it caused serious
errors.  Not that i dont think its a good idea to write a new io
library, but I wondered if it was the same problem ive encounted.

It only happens on windows that i know off, but the fix is simple...

Assuming you have a hanlde to the file called "Handle" and a Flush()
method, the following logic for read and write will allow you to
detect and prevent the problem.

Add this to the Read() method before reading takes place:

if ( Handle && (Handle->_flag & _IORW) && (Handle->_flag & (_IOREAD |
_IOWRT)) == _IOWRT )
{
       Flush();
       Handle->_flag |= _IOREAD;
}

Add this to the Write() method before writing takes place:

if ( Handle && (Handle->_flag & _IORW) && (Handle->_flag & (_IOREAD |
_IOWRT)) == _IOREAD )
{
       Flush();
       Handle->_flag |= _IOWRT;
}

Emerson
msg68782 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-06-26 12:48
It seems that python3.0 behaves better in this area, specially on
Windows. See the examples given in issue3207.

And since the 'file' type does not use FILE* anymore, the given
workaround is not necessary.
History
Date User Action Args
2022-04-11 14:56:22adminsetgithub: 44472
2008-06-26 12:48:16amaury.forgeotdarcsetstatus: open -> closed
resolution: out of date
messages: + msg68782
nosy: + amaury.forgeotdarc
2007-01-16 15:33:58jurojincreate