This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: IOError when attempting negative seek in file (Python 3.0 tutorial)
Type: behavior Stage:
Components: Documentation Versions: Python 3.0
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: georg.brandl, jsizelove
Priority: normal Keywords:

Created on 2008-08-08 00:42 by jsizelove, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg70874 - (view) Author: Jim Sizelove (jsizelove) Date: 2008-08-08 00:42
The Input and Output section of the Python 3.0 tutorial
(http://docs.python.org/dev/3.0/tutorial/inputoutput.html) shows an
example of seeking in a negative direction from the end of a file.  I
get an IOError when attempting to run the example in Python 3.0b2 on Mac
OS X 10.4 (PPC).  I don't know whether the tutorial or the code should
be changed.

>>> f = open('workfile', 'r+')
>>> f.write('0123456789abcdef')
16
>>> f.seek(-3, 2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File
"/Users/jimsize/Programming/Python/py3k/3.0b2/lib/python3.0/io.py", line
1609, in seek
    raise IOError("can't do nonzero end-relative seeks")
IOError: can't do nonzero end-relative seeks
msg70887 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-08-08 07:04
Since the file is a text file, such seeking is not possible.

I've now updated the whole section about files; in particular there was
also an outdated description of text vs. binary mode.

Committed r65595.
History
Date User Action Args
2022-04-11 14:56:37adminsetgithub: 47774
2008-08-08 07:04:48georg.brandlsetstatus: open -> closed
resolution: fixed
messages: + msg70887
2008-08-08 00:42:34jsizelovecreate