[Patches] [ python-Patches-1636874 ] File Read/Write Flushing Patch

SourceForge.net noreply at sourceforge.net
Tue Jan 16 16:33:59 CET 2007


Patches item #1636874, was opened at 2007-01-16 15:33
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1636874&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Windows
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: jurojin (jurojin)
Assigned to: Nobody/Anonymous (nobody)
Summary: File Read/Write Flushing Patch

Initial Comment:
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

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1636874&group_id=5470


More information about the Patches mailing list