From 849a972f35a6740c4784c80a8271af9f5592d7b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Sat, 18 Oct 2003 09:38:01 +0000 Subject: Patch #809535: Mention behaviour of seek on text files. Backported to 2.3. --- Doc/lib/libstdtypes.tex | 7 ++++++- Objects/fileobject.c | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Doc/lib/libstdtypes.tex b/Doc/lib/libstdtypes.tex index 62f1644..531e385 100644 --- a/Doc/lib/libstdtypes.tex +++ b/Doc/lib/libstdtypes.tex @@ -1337,7 +1337,12 @@ flush the read-ahead buffer. \method{seek()} operations will be undone at the next write. If the file is only opened for writing in append mode (mode \code{'a'}), this method is essentially a no-op, but it remains useful for files - opened in append mode with reading enabled (mode \code{'a+'}). + opened in append mode with reading enabled (mode \code{'a+'}). If the + file is opened in text mode (mode \code{'t'}), only offsets returned + by \method{tell()} are legal. Use of other offsets causes undefined + behavior. + + Note that not all file objects are seekable. \end{methoddesc} \begin{methoddesc}[file]{tell}{} diff --git a/Objects/fileobject.c b/Objects/fileobject.c index 6f90fb9..ff66117 100644 --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -1613,7 +1613,9 @@ PyDoc_STRVAR(seek_doc, "0 (offset from start of file, offset should be >= 0); other values are 1\n" "(move relative to current position, positive or negative), and 2 (move\n" "relative to end of file, usually negative, although many platforms allow\n" -"seeking beyond the end of a file).\n" +"seeking beyond the end of a file). If the file is opened in text mode,\n" +"only offsets returned by tell() are legal. Use of other offsets causes\n" +"undefined behavior." "\n" "Note that not all file objects are seekable."); -- cgit v0.12