New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
buffered io seek() buggy #51889
Comments
I've noticed a severe bug in my python 2.6.2 io module, and looking at _buffered_raw_seek in http://svn.python.org/view/python/trunk/Modules/_io/bufferedio.c?view=markup, it seems the bug is still there in the C reimplementation of buffered io classes. The problem is, if we seek a buffered stream with whence=os.SEEK_CUR, that call is directly transmitted to the underlying raw stream, which has not the same file pointer position as the buffered stream. So in the end, the file pointer doesn't get moved at the right absolute offset, but at an offset which depends of the state of the read head buffer or the write buffer. Regards, |
Could you construct a test case? |
The problem seems to be fixed in trunk (the future 2.7). I reproduce the problem with a file opened with mode "rb+" from io import open
open("tmpfile", "wb").write("abcdefgh" * 1024 + "X")
f = open("tmpfile", "rb+")
print f.read(1) # "a"
f.seek(0, 1)
print f.read(1) # should be "b", 2.6 returns "X" |
My bad, I had looked at _buffered_raw_seek, not buffered_seek >_< So concerning python2.6, isn't that just possible to backport _pyio (and its test suite) to it (renamed as io.py) ? They seem to offer the same functionality, except that _pyio is much more robust than io.py (the code around seek(), in particular, is much more complete). |
I would not be against it, but someone has to provide a patch. |
Hum, with a selective merge (tortoiseSVN makes it easy), backporting _pyio should be doable in a decent time. Triaging pertinent tests should be more brain damaging :p |
Well, here is a patch for the seek() methods of io module, in python2.6 maintenance branch. |
BufferedRandom's seek() is still borken in the latest svn revision of python2.6 (I haven't checked python2.7 yet), so here is a new, smaller patch, tested with the 6 IO-related test suites this time, on win32 and linux. |
The patch itself... |
Hello I advocate the inclusion of this patch to the 2.6 maintenance branch, because currently the io module in this branch (which is still the most recent 2.X version released) is simply broken. Or should we rather backport the much more evoluated io of trunk to py2.6 ? |
Committed in r81203. Thank you, Pascal! |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: