mirror of https://github.com/python/cpython
Make GzipFile an iterator. Closes bug #532621.
This commit is contained in:
parent
fbb556df15
commit
cacbdf6229
10
Lib/gzip.py
10
Lib/gzip.py
|
@ -351,6 +351,16 @@ class GzipFile:
|
||||||
for line in L:
|
for line in L:
|
||||||
self.write(line)
|
self.write(line)
|
||||||
|
|
||||||
|
def __iter__(self):
|
||||||
|
return self
|
||||||
|
|
||||||
|
def next(self):
|
||||||
|
line = self.readline()
|
||||||
|
if line:
|
||||||
|
return line
|
||||||
|
else:
|
||||||
|
raise StopIteration
|
||||||
|
|
||||||
|
|
||||||
def _test():
|
def _test():
|
||||||
# Act like gzip; with -d, act like gunzip.
|
# Act like gzip; with -d, act like gunzip.
|
||||||
|
|
Loading…
Reference in New Issue