[ python-Bugs-1252149 ] IOError after normal write

SourceForge.net noreply at sourceforge.net
Fri Aug 12 22:56:52 CEST 2005


Bugs item #1252149, was opened at 2005-08-04 19:30
Message generated for change (Comment added) made by patrick_gerken
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1252149&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: Python 2.4
>Status: Deleted
>Resolution: Invalid
Priority: 5
Submitted By: Patrick Gerken (patrick_gerken)
Assigned to: Nobody/Anonymous (nobody)
Summary: IOError after normal write

Initial Comment:
After some Bughunting of Code with ConfigParser stuff 
which worked under Linux and didn't under Windows, it
all boiled down to these three lines of codes:

fp = open('bla','w+'
fp.readline()
fp.write('bla')
Traceback (most recent call last):
  File "<pyshell#11>", line 1, in ?
    fp.write('bla')
IOError: (0, 'Error')

The same test under linux is a success.

These teste have been run on the newest XP with 
python 2.4.1.

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

>Comment By: Patrick Gerken (patrick_gerken)
Date: 2005-08-12 20:56

Message:
Logged In: YES 
user_id=1324112

I could not believe it and was searching for verification for this 
for a long time. If somebody does not believe it like I did:
The C faq from usenet(Which I should have checked first...) 
answers this question too, and delivers two references:
References: ANSI Sec. 4.9.5.3 
ISO Sec. 7.9.5.3 




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

Comment By: Tim Peters (tim_one)
Date: 2005-08-04 19:51

Message:
Logged In: YES 
user_id=31435

Well, this is pilot error, inherited from the limitations of C I/O:  
the effect of mixing reads with writes on a file open for update 
is entirely undefined unless a file-positioning operation occurs 
between them (for example, a seek()).  I can't guess what 
you expect to happen, but seems most likely that what you 
intend could be obtained reliably by inserting

    fp.seek(fp.tell())

between your readline() and your write().

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

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


More information about the Python-bugs-list mailing list