Message302
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();
|
|
Date |
User |
Action |
Args |
2008-02-20 17:16:49 | admin | link | issue417665 messages |
2008-02-20 17:16:49 | admin | create | |
|