[ python-Bugs-1521491 ] file.seek() influelce write() when opened with a+ mode

SourceForge.net noreply at sourceforge.net
Thu Jul 13 00:04:18 CEST 2006


Bugs item #1521491, was opened at 2006-07-12 22:04
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1521491&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: Python Interpreter Core
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Submitted By: Lior (rudnik_lior)
Assigned to: Nobody/Anonymous (nobody)
Summary: file.seek() influelce write() when opened with a+ mode

Initial Comment:
Python 2.5b1 (r25b1:47027, Jun 20 2006, 09:31:33)

Assuming documentation is correct: (from seek() help
"Note that if the file is opened for appending (mode
'a' or 'a+'), any seek() operations will be undone at
the next write"

Doing the following is __not__ undoing the seek
operation after calling this a few times (Simplified
code snippet):

from __future__ import with_statement
with open(path,'a+') as f:
    f.seek(0,2) # go to end
    pos = f.tell() 
    f.seek(0,0)
    line = f.readline().strip()
    f.seek(0,2) # go to end, not effective if opened
with mode a/a+ (currently bug?)
    f.write("something")

Calling the above code repeatedly didnt increase the
file size beyond 166 bytes (in my code)



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

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


More information about the Python-bugs-list mailing list