[issue7640] buffered io seek() buggy
report at bugs.python.org
Tue Jan 5 20:38:10 CET 2010
New submission from Pascal Chambon <chambon.pascal at gmail.com>:
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.
When using os.SEEK_CUR, it would be necessary to call tell() or to manually compute offsets, so that the seek() works as expected.
title: buffered io seek() buggy
versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2
Python tracker <report at bugs.python.org>
More information about the Python-bugs-list