diff options
| author | Brett Cannon <bcannon@gmail.com> | 2007-04-27 22:35:57 (GMT) |
|---|---|---|
| committer | Brett Cannon <bcannon@gmail.com> | 2007-04-27 22:35:57 (GMT) |
| commit | a801b6a1fd3f2df1fb47c30f5d329bd80e4cbebc (patch) | |
| tree | 7bc681515ae65d30b30f52a83e0e90eb84594f21 | |
| parent | c22aee03c6a55775e55136206d81089244d17f4b (diff) | |
| download | cpython-a801b6a1fd3f2df1fb47c30f5d329bd80e4cbebc.zip cpython-a801b6a1fd3f2df1fb47c30f5d329bd80e4cbebc.tar.gz cpython-a801b6a1fd3f2df1fb47c30f5d329bd80e4cbebc.tar.bz2 | |
Backport r54712: document that calling file.next() on a file open for writing
leads to undefined behaviour.
| -rw-r--r-- | Doc/lib/libstdtypes.tex | 17 | ||||
| -rw-r--r-- | Misc/NEWS | 7 |
2 files changed, 16 insertions, 8 deletions
diff --git a/Doc/lib/libstdtypes.tex b/Doc/lib/libstdtypes.tex index a4d38f9..e4486f4 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} @@ -25,6 +25,13 @@ Library run in verbose mode. +Documentation +------------- + +- Bug #1569057: Document that calling file.next() on a file open for writing + has undefined behaviour. Backport of r54712. + + What's New in Python 2.5.1? ============================= |
