summaryrefslogtreecommitdiffstats
path: root/Doc/lib
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2007-04-08 04:29:32 (GMT)
committerBrett Cannon <bcannon@gmail.com>2007-04-08 04:29:32 (GMT)
commit55a1864832a02725b339a9ae98dd6849251c623b (patch)
tree23cd003e8a130572a8081a75e124542fa12a22af /Doc/lib
parentbf618564279a872e046d6540a560acce86503acb (diff)
downloadcpython-55a1864832a02725b339a9ae98dd6849251c623b.zip
cpython-55a1864832a02725b339a9ae98dd6849251c623b.tar.gz
cpython-55a1864832a02725b339a9ae98dd6849251c623b.tar.bz2
Doc that file.next() has undefined behaviour when called on a file opened with
'w'. Closes bug #1569057. To be backported once 2.5 branch is unfrozen.
Diffstat (limited to 'Doc/lib')
-rw-r--r--Doc/lib/libstdtypes.tex17
1 files changed, 9 insertions, 8 deletions
diff --git a/Doc/lib/libstdtypes.tex b/Doc/lib/libstdtypes.tex
index 3cad43b..0ad2ebc 100644
--- a/Doc/lib/libstdtypes.tex
+++ b/Doc/lib/libstdtypes.tex
@@ -1615,14 +1615,15 @@ A file object is its own iterator, for example \code{iter(\var{f})} returns
iterator, typically in a \keyword{for} loop (for example,
\code{for line in f: print line}), the \method{next()} method is
called repeatedly. This method returns the next input line, or raises
-\exception{StopIteration} when \EOF{} is hit. In order to make a
-\keyword{for} loop the most efficient way of looping over the lines of
-a file (a very common operation), the \method{next()} method uses a
-hidden read-ahead buffer. As a consequence of using a read-ahead
-buffer, combining \method{next()} with other file methods (like
-\method{readline()}) does not work right. However, using
-\method{seek()} to reposition the file to an absolute position will
-flush the read-ahead buffer.
+\exception{StopIteration} when \EOF{} is hit when the file is open for
+reading (behavior is undefined when the file is open for writing). In
+order to make a \keyword{for} loop the most efficient way of looping
+over the lines of a file (a very common operation), the
+\method{next()} method uses a hidden read-ahead buffer. As a
+consequence of using a read-ahead buffer, combining \method{next()}
+with other file methods (like \method{readline()}) does not work
+right. However, using \method{seek()} to reposition the file to an
+absolute position will flush the read-ahead buffer.
\versionadded{2.3}
\end{methoddesc}