|
From: <no...@so...> - 2001-04-20 16:04:45
|
Bugs item #417665, was updated on 2001-04-20 09:03 You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=112867&aid=417665&group_id=12867 Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: brian zimmer (bzimmer) Assigned to: Nobody/Anonymous (nobody) >Summary: open(filename, "a") fails to append Initial Comment: Opening a file in append mode does not append to the file but instead starts to write from index 0 which results in overwriting the existing data. To fix the problem, remove the seek() call in flush() as it is not needed. The diff is below. Also see the attached TestCase to demonstrate the problem (use the unittest.py from CPython 2.1). To run the unittest: $> jython pyfiletest.py Index: org/python/core/PyFile.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyFile.java,v retrieving revision 2.18 diff -u -r2.18 PyFile.java --- org/python/core/PyFile.java 2001/03/13 20:21:27 2.18 +++ org/python/core/PyFile.java 2001/04/20 16:02:40 @@ -455,7 +455,6 @@ } public void flush() throws java.io.IOException { - file.seek(bufferStart); file.write(buffer, 0, dataSize); bufferModified = false; file.getFD().sync(); @@ -463,8 +462,7 @@ public void close() throws java.io.IOException { if (writing && bufferModified) { - file.seek(bufferStart); - file.write(buffer, 0, (int)dataSize); + this.flush(); } file.close(); ---------------------------------------------------------------------- You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=112867&aid=417665&group_id=12867 |