Revert revert: fix StopIteration raising
A for loop raises StopIteration by itself after using all elements. Thus, instead of yielding a stop iteration we must return without yielding any more objects.
Alternatively, we could send a StopIteration to the generator if the obj is a StopIteration
gen.send(StopIteration)