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:
Corey Bryant 2018-07-13 11:22:14 -04:00
parent c58e5e02af
commit f537389811
2 changed files with 2 additions and 2 deletions

View File

@ -34,7 +34,7 @@ class SimpleIterator(object):
yield chunk
chunk = read_chunk()
else:
raise StopIteration()
return
class TestSizeCheckedIter(testtools.TestCase):

View File

@ -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)