[Python-bugs-list] [ python-Bugs-432373 ] file.tell() gives wrong value

noreply@sourceforge.net noreply@sourceforge.net
Tue, 12 Jun 2001 06:52:01 -0700


Bugs item #432373, was updated on 2001-06-12 04:09
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=432373&group_id=5470

Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Elmar Sonnenschein (eso)
Assigned to: Nobody/Anonymous (nobody)
Summary: file.tell() gives wrong value

Initial Comment:
Invoking tell() on a file object will return a wrong 
(arbitrary?) value if called before seeking. Example: 
The following script

f = open('c:\test.xyz')
print 'pos: ' + `f.tell()`
print 'read: ' + f.read(3)
print 'pos: ' + `f.tell()`
f.seek(0)
print 'pos: ' + `f.tell()`
print 'read: ' + f.read(3)
print 'pos: ' + `f.tell()`
f.close()

will yield the following result:

pos: 0
read: XYZ
pos: 3587  <-- wrong value
pos: 0
read: XYZ
pos: 3

Only the return value of tell is wrong, not the actual 
file position, i. e. a consecutive read() will return 
the correct bytes. It doesn't help to seek before 
reading, only seeking _after_ reading will set the 
return value of tell() correctly.

File size of 'test.xyz' was 3.822.167 Bytes.

----------------------------------------------------------------------

Comment By: Hans Nowak (zephyrfalcon)
Date: 2001-06-12 06:52

Message:
Logged In: YES 
user_id=173607

Works fine for me... I'm using Python 2.1 on Windows NT 4, 
sp 5. :-/  Maybe it's platform dependent?


----------------------------------------------------------------------

Comment By: Elmar Sonnenschein (eso)
Date: 2001-06-12 04:15

Message:
Logged In: YES 
user_id=145214

Checked on Python 2.0, 2.1, and ActivePython 2.1 - always 
the same.

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=432373&group_id=5470