Python 3: use next(foo) instead of foo.next()

This is compatible with both versions of Python.

Change-Id: I50f9b2fa0c2333010c10eb4db34d972aa379f0e3
Merge "Python 3: use next(foo) instead of foo.next()"