[New-bugs-announce] [issue4633] file.tell() gives wrong result
Yavuz Onder
report at bugs.python.org
Thu Dec 11 16:31:17 CET 2008
New submission from Yavuz Onder <yavuz at teksavvy.com>:
I find that file.tell returns not the byte offset of the next byte, but
possibly the byte offset of the next block to be read. I find it always
to be a multiple of 1024. Following is a demo of the bug. where I read a
few lines into a text file, step back by the length of the last read
line, read again, and do not find the same data. What is returned is the
tail part of a line way down in the file. I woeked around by keeping
track of the file pointer, and seek worked fine. tell() is at fault.
----------demonstration on a text file
Python 2.5.1 (r251:54863, Nov 14 2007, 16:00:54)
[GCC 3.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> jf=open('junk','r')
>>> line=jf.next()
>>> line
'\n'
>>> line=jf.next()
>>> line
'See COPYING file in the same directory as this one for license.\n'
>>> line=jf.next()
>>> line
'\n'
>>> line=jf.next()
>>> line
'Thank you for trying this utility. I had great fun putting it\n'
>>> line=jf.next()
>>> line
'together, and I hope users will find it useful.\n'
>>> jf.seek(len(line),1)
>>> line=jf.next()
>>> line
'gle says Maps will not work without it. file:// URLs are \n'
----------
components: None
messages: 77617
nosy: yavuz164
severity: normal
status: open
title: file.tell() gives wrong result
versions: Python 2.5
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4633>
_______________________________________
More information about the New-bugs-announce
mailing list