Bugs item #1521491, was opened at 2006-07-12 22:04 Message generated for change (Comment added) made by gbrandl 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: Tim Peters (tim_one) 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) ---------------------------------------------------------------------- >Comment By: Georg Brandl (gbrandl) Date: 2006-07-28 18:54 Message: Logged In: YES user_id=849994 Perhaps you can try in on Windows, Tim... ---------------------------------------------------------------------- Comment By: Lior (rudnik_lior) Date: 2006-07-28 13:35 Message: Logged In: YES user_id=1364480 This issue is on windows XP. Wasnt tested on other versions (only 2.5b1 and b2) I expect the code to always write at the end according to the documentation. However if I user file seek (opend as A+) to read from begining of the file, the write also goes to begining of file. Note - in the code snippet, please remove the last f.seek(0,2) to see the problem! (it should have been in a comment) ---------------------------------------------------------------------- Comment By: Georg Brandl (gbrandl) Date: 2006-07-13 07:43 Message: Logged In: YES user_id=849994 I also cannot see any problem with the above code and can append to a file indefinitely. What exactly are you expecting the code to do, and what do you get? Which OS is this? ---------------------------------------------------------------------- Comment By: Neal Norwitz (nnorwitz) Date: 2006-07-13 06:29 Message: Logged In: YES user_id=33168 This seems to work for me on Linux. Maybe we are testing differently. What o/s and version are you using? Does this work with Python 2.4? Can you attach a complete test case that demonstrates this problem? Thanks. ---------------------------------------------------------------------- Comment By: Lior (rudnik_lior) Date: 2006-07-12 22:09 Message: Logged In: YES user_id=1364480 Re-tried the code with empty file - it doesnt grow beyond creating and writting at position 0 so it seems the seek does influence the write position. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1521491&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com