Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5606801

Browse files
committed
Make read() and readlines() conform more to the file object interface:
the default arg for read() is -1, not None, and readlines() has an optional argument (which for now is ignored).
1 parent 4acc25b commit 5606801

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

Lib/gzip.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,12 @@ def write(self,data):
139139
def writelines(self,lines):
140140
self.write(string.join(lines))
141141

142-
def read(self, size=None):
142+
def read(self, size=-1):
143143
if self.extrasize <= 0 and self.fileobj is None:
144144
return ''
145145

146146
readsize = 1024
147-
if not size: # get the whole thing
147+
if size < 0: # get the whole thing
148148
try:
149149
while 1:
150150
self._read(readsize)
@@ -281,7 +281,7 @@ def readline(self):
281281
bufs.append(c)
282282
readsize = readsize * 2
283283

284-
def readlines(self):
284+
def readlines(self, ignored=None):
285285
buf = self.read()
286286
lines = string.split(buf, '\n')
287287
for i in range(len(lines)-1):

0 commit comments

Comments
 (0)