[Python-Dev] Re: [Patch #100740] gzip: readline(), readlines() patch

Andrew Kuchling akuchlin@mems-exchange.org
Fri, 28 Jul 2000 08:29:19 -0400


On Fri, Jul 28, 2000 at 03:25:36AM -0700, noreply@sourceforge.net wrote:
>Patch #100740 has been updated. 
>gvanrossum wrote:
>Almost right.  The docs for file objects specifically imply that a
>negative arg to readline() or a zero arg to readlines() is the same as
>no args; your defaults are sys.maxint so an explicit -1 or 0 won't do
>the right thing. (This is important for wrapper classes that want to

Which docs say this?  I looked at Doc/lib/libstdtypes.tex to get the
semantics:

\begin{methoddesc}[file]{readline}{\optional{size}}
  ...   If the \var{size} argument is present and
  non-negative, it is a maximum byte count (including the trailing
  newline) and an incomplete line may be returned. ...
\end{methoddesc}

\begin{methoddesc}[file]{readlines}{\optional{sizehint}}
  ... If the optional \var{sizehint} argument is
  present, instead of reading up to \EOF{}, whole lines totalling
  approximately \var{sizehint} bytes (possibly after rounding up to an
  internal buffer size) are read.
\end{methoddesc}

Neither text mentions the special cases for -1 and 0 in each function.
Fixing the patch to get this right is trivial, but I think the docs
need to be updated to mention this.

--amk