file .seek() under MS-Windows

Fredrik Lundh fredrik at pythonware.com
Wed Jun 19 17:58:32 EDT 2002


Frank Schaefer wrote:

> The following code:
>
> fh = open("myfile.pot", "r")
> ...
> fh.seek(-1,1)
> ...
>
> produces an error:
> [IOError 22] Invalid Argument
>
> under MS Windows (XP). It works fine under Unix, though
> (for years).

really?

$ uname -sr
Linux 2.4.7-10
$ python
>>> fh = open("somefile")
>>> fh.seek(-1, 1)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
IOError: [Errno 22] Invalid argument

> uname -sr
SunOS 5.8
>>> fh = open("somefile")
>>> fh.seek(-1, 1)
Traceback (innermost last):
  File "<stdin>", line 1, in ?
IOError: [Errno 22] Invalid argument

> uname -sr
OSF1 V4.0
>>> fh = open("somefile")
>>> fh.seek(-1, 1)
Traceback (innermost last):
  File "<stdin>", line 1, in ?
IOError: [Errno 22] Invalid argument

(etc)

according to the Unix specification, the underlying fseek
operation is supposed to generate this error if you attempt
to set the file pointer to a negative value.

what did you expect it to do?

</F>





More information about the Python-list mailing list