From: gmcm at hypernet.com (Gordon McMillan)
Date: Tue, 18 May 1999 09:48:14 -0500
Subject: Bug? On WindowsNT, f.seek() and f.tell() aren't symmetric
In-Reply-To: <7hrhns$7o4@senator-bedfellow.MIT.EDU>
Message-ID: <1285083374-170414649@hypernet.com>
Content-Length: 1505
X-UID: 1860                                                 

Oliver Steele writes:

> My reading of the Python Library documentation
> <http://www.python.org/doc/lib/bltin-file-objects.html> is that,
> regardless of file modes, f.seek(f.tell()) should be a noop
> (assuming f is bound to an open file):
/snip/
> Not so. On a Windows machine (specifically, an SGI running WindowsNT
> and Python 1.5.2 final), the function below prints 'a\012' for the
> first line and '\012' for the second.  Changing the file open mode
> to 'rb' or running the program on a Mac or UNIX machine works fine.
/snip/
> The upshot of this is that it's possible to develop a Python program
> under MacOS or UNIX, using the documentation available on those
> platforms, that fails under NT -- in other words, it demotes Python
> to the status of a 'write once test everywhere language'. 

I'm sorry that you got the impression that Python promises WORE. In 
general, Python is ever-so-slightly more portable than the underlying 
c runtime libs are conformant. WIth the low-level routines, you 
generally get your c runtime lib's behavior, warts and all. It's true 
that only a subset of the gotchas are documented, but that's a never 
ending task.

Someplace (probably the MSVC docs) I've seen the warning that seek
and tell are may be less-than-useful on a file opened in text mode. 

Languages which promise WORE are no more successful overall. And 
Python has the advantage that it's easy to work around the problem, 
while in that other language it's damn near impossible.

- Gordon




