Catch the 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."
Closes-Bug: #1785309
Change-Id: Ib751b680b7357782cb5359526e1e83ee8c5c80dd