Nobody nobody at
Tue Jul 5 10:14:13 CEST 2011

On Sun, 03 Jul 2011 16:58:24 -0700, amir chaouki wrote:

> the problem is when i use the seek function on windows it gives me
> false results other then the results on *ux. the file that i work with
> are very large about 10mb.

This is probably an issue with how the underlying C functions behave on
Windows, related to the CRLF<->LF conversions when a file is opened in
text mode.

The Python library documention for the .seek() method says:

> If the file is opened in text mode (without 'b'), only offsets returned
> by tell() are legal. Use of other offsets causes undefined behavior.

IOW, you can't use computed offsets with files opened in text mode
(although in practice this will work for platforms other than Windows). If
you want to use computed offsets, open the file in binary mode and strip
the trailing CRs yourself.

And 10MB isn't "very large"; it's not even "large". You normally only
start running into problems with files which are 2GiB (2,147,483,648
bytes) or more (i.e. if you can't fit the size into a signed 32-bit

More information about the Python-list mailing list