mirror of https://github.com/python/cpython
Make StringIO its own iterator, similar to real files.
(This should also be done to cStringIO.)
This commit is contained in:
parent
5b8132ffa3
commit
c1265bd9a6
|
@ -59,7 +59,15 @@ class StringIO:
|
|||
self.softspace = 0
|
||||
|
||||
def __iter__(self):
|
||||
return iter(self.readline, '')
|
||||
return self
|
||||
|
||||
def next(self):
|
||||
if self.closed:
|
||||
raise StopIteration
|
||||
r = self.readline()
|
||||
if not r:
|
||||
raise StopIteration
|
||||
return r
|
||||
|
||||
def close(self):
|
||||
"""Free the memory buffer.
|
||||
|
|
Loading…
Reference in New Issue