[issue12116] io.Buffer*.seek() doesn't seek if "seeking leaves us inside the current buffer"

STINNER Victor report at bugs.python.org
Thu May 19 18:39:34 CEST 2011


STINNER Victor <victor.stinner at haypocalc.com> added the comment:

And how can I seek the raw file to zero?

Using buffer.raw.seek(0), buffer.tell() becomes inconsistent:

$ ./python 
Python 3.2.1b1 (3.2:bd5e4d8c8080, May 15 2011, 10:22:54) 
>>> buffer=open('setup.py', 'rb')
>>> buffer.read(1)
>>> buffer.tell()
1
>>> buffer.raw.tell()
4096
>>> buffer.raw.seek(0)
0
>>> buffer.raw.tell()
0
>>> buffer.tell()
-4095

Same problem with os.lseek():

$ ./python 
Python 3.2.1b1 (3.2:bd5e4d8c8080, May 15 2011, 10:22:54) 
>>> import os
>>> buffer=open("setup.py", "rb")
>>> buffer.read(1)
>>> os.lseek(buffer.fileno(), 0, 0)
0
>>> buffer.raw.tell()
0
>>> buffer.tell()
-4095

----------

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


More information about the Python-bugs-list mailing list