[New-bugs-announce] [issue7640] buffered io seek() buggy

Pascal Chambon 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.

Regards, 
Pascal

----------
components: IO
messages: 97275
nosy: pakal
severity: normal
status: open
title: buffered io seek() buggy
type: behavior
versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7640>
_______________________________________


More information about the New-bugs-announce mailing list