move StopIteration to core; close #2518