[Python-bugs-list] [ python-Bugs-416906 ] readlines() corrupts file opened for 'a'

noreply@sourceforge.net noreply@sourceforge.net
Wed, 18 Apr 2001 02:39:03 -0700


Bugs item #416906, was updated on 2001-04-17 18:10
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=416906&group_id=5470

Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
>Assigned to: Guido van Rossum (gvanrossum)
Summary: readlines() corrupts file opened for 'a'

Initial Comment:
Version 2.1 final release for Windows (using Idle)
Windows 98 2nd edition

f=open('c:\My Documents\textfile.txt', 'a')
f.write('hello file\n')
f.readlines()

raises the following error - it probably should.

Traceback (most recent call last):
  File "<pyshell#6>", line 1, in ?
    f.readlines()
IOError: [Errno 9] Bad file descriptor

However, the file gets a bunch of garbage appended to 
it.  In some cases, the entire contents of the GUI 
window gets appended.   

In Redhat 6.2 (also with Version 2.1 Final)the same 
code just erases the file.

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

>Comment By: Tim Peters (tim_one)
Date: 2001-04-18 02:39

Message:
Logged In: YES 
user_id=31435

Back to you, Guido:  you're the one fond of arguing that MS 
is within its rights to do anything whatsoever when the 
rules for C stdio are broken <wink>.

Seriously, MS won't "fix" this (they'll deny it's broken).  
Same kind of thing happens in straight C under MS.

BTW, note that Anonymous did not claim it's an MS bug:  two 
different bugs were claimed (Win98SE appends crap, RH 6.2 
destroys the whole file).

I don't see a realistic choice here but to say "hmm -- 
tough luck, don't do that".

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

Comment By: Guido van Rossum (gvanrossum)
Date: 2001-04-17 21:17

Message:
Logged In: YES 
user_id=6380

Assigned to Tim, because he believes that this is a
Microsoft bug.

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

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