[Patches] [Patch #100740] gzip: readline(), readlines() patch

noreply@sourceforge.net noreply@sourceforge.net
Fri, 28 Jul 2000 09:25:16 -0700


Patch #100740 has been updated. 

Project: 
Category: library
Status: Open
Summary: gzip: readline(), readlines() patch

Follow-Ups:

Date: 2000-Jul-05 18:15
By: akuchling

Comment:
Patch from Wolfgang Grafen <wolfgang.grafen@marconicomms.com> that I didn't want to lose.  From his e-mail:

- readline accepts readsize argument
- readlines accepts readsize argument
- readlines accepts optional 'strip_cr' arguments, which is often convenient for me and also speeds up the routine :)

[amk] The strip_cr thing is a non-starter, but I'll look at adding the other changes.
-------------------------------------------------------

Date: 2000-Jul-27 13:03
By: gvanrossum

Comment:
His addition of readsize to readline() doesn't do the same as readline(n) does for regular files -- there it reads at most n characters, period.

The only part of this patch I like is the readsize argument to readlines(), which *does* (roughly) do the same as for regular files.

You can rework this to implement readline(maxread=-1) and readlines(sizehint=0) and then I'd be okay.
-------------------------------------------------------

Date: 2000-Jul-27 19:27
By: akuchling

Comment:
Completely revised this patch and changed status from 'rejected' to 'open'.  This version gives now the optional
integer arguments to .readline() and .readlines() the same
semantics as they have for regular file objects.  

(The patch also rearranges a few import statements, and completes a sentence fragment in a comment.)

-------------------------------------------------------

Date: 2000-Jul-28 03:25
By: gvanrossum

Comment:
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 implement the same conventions.)

This is my only objection; you can check it in if you fix this.
-------------------------------------------------------

Date: 2000-Jul-28 05:41
By: akuchling

Comment:
Two-line change to give -1 and 0 the correct semantics
for readline and readlines.  
-------------------------------------------------------

Date: 2000-Jul-28 06:39
By: gvanrossum

Comment:
Argh!  You seem to have reversed the -1 and 0.  (I apologize for the confusion.)

The default is readline(-1), readlines(0).
-------------------------------------------------------

Date: 2000-Jul-28 09:25
By: akuchling

Comment:
Revised patch to swap the default values.

I also want to beef up the test suite to exercise the new functionality --
will work on that tonight.
-------------------------------------------------------

-------------------------------------------------------
For more info, visit:

http://sourceforge.net/patch/?func=detailpatch&patch_id=100740&group_id=5470