Handle StopIteration for Py3.7 PEP 0479
Replace raise of StopIteration with return. PEP 0479, https://www.python.org/dev/peps/pep-0479/, makes the following change: "when StopIteration is raised inside a generator, it is replaced it with RuntimeError". And states: "If raise StopIteration occurs directly in a generator, simply replace it with return." Change-Id: Ia7d6af7165077aa93c76185c28c355c06a202088 Closes-Bug: #1781627
This commit is contained in:
parent
c58e5e02af
commit
f537389811
|
@ -34,7 +34,7 @@ class SimpleIterator(object):
|
|||
yield chunk
|
||||
chunk = read_chunk()
|
||||
else:
|
||||
raise StopIteration()
|
||||
return
|
||||
|
||||
|
||||
class TestSizeCheckedIter(testtools.TestCase):
|
||||
|
|
|
@ -87,7 +87,7 @@ class TestUtils(test_utils.BaseTestCase):
|
|||
yield chunk
|
||||
iteration += 1
|
||||
if iteration >= max_iterations:
|
||||
raise StopIteration()
|
||||
return
|
||||
|
||||
def _test_reader_chunked(self, chunk_size, read_size, max_iterations=5):
|
||||
generator = self._create_generator(chunk_size, max_iterations)
|
||||
|
|
Loading…
Reference in New Issue