Issue417665
Created on 2001-04-20.16:03:53 by bzimmer, last changed 2001-07-16.10:59:36 by bckfnn.
File name |
Uploaded |
Description |
Edit |
Remove |
pyfiletest.py
|
bzimmer,
2001-04-20.16:03:53
|
a unittest for PyFile |
|
|
msg302 (view) |
Author: Brian Zimmer (bzimmer) |
Date: 2001-04-20.16:03:53 |
|
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();
|
msg303 (view) |
Author: Brian Zimmer (bzimmer) |
Date: 2001-04-25.19:54:29 |
|
Logged In: YES
user_id=37674
After some more testing, I don't the patch fixes the problem
for all cases.
|
msg304 (view) |
Author: Leonkev (vleonkev) |
Date: 2001-07-11.12:20:48 |
|
Logged In: YES
user_id=266902
When you are in append mode,
write some data and flush twice before closing.
The result is: duplicated data in file
|
msg305 (view) |
Author: Finn Bock (bckfnn) |
Date: 2001-07-16.10:59:36 |
|
Logged In: YES
user_id=4201
Fixed in PyFile.java: 2.20;
The fix only ensure that the filepointer is located at the
end right after the open. Some unixes always write at the
end of the file regardless of the filepointer but that is
*not* the case for jython.
|
|
Date |
User |
Action |
Args |
2001-04-20 16:03:53 | bzimmer | create | |
|