Make read() and readlines() conform more to the file object interface:
authorGuido van Rossum <guido@python.org>
Wed, 2 Feb 2000 16:51:06 +0000 (16:51 +0000)
committerGuido van Rossum <guido@python.org>
Wed, 2 Feb 2000 16:51:06 +0000 (16:51 +0000)
the default arg for read() is -1, not None, and readlines() has an
optional argument (which for now is ignored).

Lib/gzip.py

index c0aff91150c47e445f7d39e218e6eedea60c08cc..0ba2ac22f7539565a01130e6ebf4c4a477801244 100644 (file)
@@ -139,12 +139,12 @@ class GzipFile:
     def writelines(self,lines):
         self.write(string.join(lines))
 
-    def read(self, size=None):
+    def read(self, size=-1):
         if self.extrasize <= 0 and self.fileobj is None:
             return ''
 
         readsize = 1024
-        if not size:        # get the whole thing
+        if size < 0:        # get the whole thing
             try:
                 while 1:
                     self._read(readsize)
@@ -281,7 +281,7 @@ class GzipFile:
             bufs.append(c)
             readsize = readsize * 2
 
-    def readlines(self):
+    def readlines(self, ignored=None):
         buf = self.read()
         lines = string.split(buf, '\n')
         for i in range(len(lines)-1):