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: appended file on Windows reads arbitrary data
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: muimi, tim.peters
Priority: normal Keywords:

Created on 2006-05-15 09:08 by muimi, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg28527 - (view) Author: muimi (muimi) Date: 2006-05-15 09:08
checked with versions 2.3 & 2.4.2 on Windows 2000 & XP

reading an appended file without resetting its
current position causes reading/writing of arbitrary data.
this appears to be related to the MS Visual Studio C
library.

def bug(filename):
    af=open(filename,'a+')
    af.write('\nlast line?')
    print af.tell()
    d=af.read() # this causes a read/write problem
    print len(d), af.tell()
    af.close()
msg28528 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2006-05-15 16:58
Logged In: YES 
user_id=31435

Yes, and this is inherited from the platform C library,
which conforms to the C standard in this respect:  all
behavior is undefined if you read after write, or write
after read, without a file-positioning operation (typically
a seek) between them.  So don't do that.  Closing as not-a-bug.
History
Date User Action Args
2022-04-11 14:56:17adminsetgithub: 43357
2006-05-15 09:08:06muimicreate