Issue1793

classification
Title: relative file.seek fails in read/write mode
Type: behaviour Severity: major
Components: Core Versions: Jython 2.5
process
Status: open Resolution: accepted
Dependencies: Superseder:
Assigned To: Nosy List: fwierzbicki, tuck182, zyasoft
Priority: high Keywords:

Created on 2011-08-24.23:08:20 by tuck182, last changed 2014-06-19.05:47:50 by zyasoft.

Files
File name Uploaded Description Edit Remove
test-seek.py tuck182, 2011-08-24.23:08:20 test script
Messages
msg6613 (view) Author: Matt Tucker (tuck182) Date: 2011-08-24.23:08:20
Doing a file.seek(N, 1) fails for files opened in read/write mode ("r+" or "rb+"). This first manifested for me with mutagen corrupting m4a files when writing tags.


Output from the attached script (on two different systems, Linux and OS-X) gives:

--- OS-X ---
$ python ./script/test-seek.py 
Python 2.6.1
Darwin Kernel Version 10.8.0: Tue Jun  7 16:32:41 PDT 2011; root:xnu-1504.15.3~1/RELEASE_X86_64
No errors

$ jython ./script/test-seek.py 
Jython 2.5.2
Java HotSpot(TM) 64-Bit Server VM, 20.1-b02-384, Apple Inc.
Traceback (most recent call last):
  File "./script/test-seek.py", line 31, in <module>
    assert f.tell() == x, "before read: pos should be %d but was %d" % (x, f.tell())
AssertionError: before read: pos should be 253 but was 254


--- Linux ---
$ python script/test-seek.py 
Python 2.7.1+
#42-Ubuntu SMP Mon Apr 11 03:31:50 UTC 2011
No errors

$ java -jar target/lib/jython-standalone-2.5.2.jar script/test-seek.py 
Jython 2.5.2
OpenJDK Server VM, 20.0-b11, Sun Microsystems Inc.
Traceback (most recent call last):
  File "script/test-seek.py", line 31, in <module>
    assert f.tell() == x, "before read: pos should be %d but was %d" % (x, f.tell())
AssertionError: before read: pos should be 253 but was 254
msg8716 (view) Author: Jim Baker (zyasoft) Date: 2014-06-19.05:47:50
Target beta 4
History
Date User Action Args
2014-06-19 05:47:50zyasoftsetpriority: normal -> high
resolution: accepted
messages: + msg8716
nosy: + zyasoft
2013-02-25 19:22:55fwierzbickisetpriority: normal
nosy: + fwierzbicki
versions: + Jython 2.5, - 2.5.2
2011-08-24 23:08:20tuck182create