You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
file.write() after file.read() adds text to the end of the file #70103
bpo-12215: TextIOWrapper: issues with interlaced read-write
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2015-12-20.09:55:38.642>created_at=<Date2015-12-20.09:44:25.956>labels= ['type-bug', 'expert-IO']
title='file.write() after file.read() adds text to the end of the file'updated_at=<Date2015-12-20.09:56:50.377>user='https://bugs.python.org/AdamWasik'
>>> file=open(r"C:\adam.txt","r+")
>>> file.read()
'TEXT TEXT TEXT TEXT TEXT TEXT TEXT\nTEXT TEXT TEXT TEXT TEXT TEXT TEXT\nTEXT TE
XT TEXT TEXT TEXT TEXT TEXT\nTEXT TEXT TEXT TEXT TEXT TEXT TEXT\nTEXT TEXT TEXT
TEXT TEXT TEXT TEXT\nTEXT TEXT TEXT TEXT TEXT TEXT TEXT'
>>> file.seek(0,0)
0
>>> file.read(1)
'T'
>>> file.tell()
1
>>> file.write("NEW")
3
>>> file.tell() # Why 217 rather than 4. Text is added at the end file
217
>>>
Activity
AdamWasik commentedon Dec 20, 2015
AdamWasik commentedon Dec 20, 2015
duplicate of the issue bpo-12215