2to3: Apply next fixer. #3249

Merged
merged 1 commit into from Apr 15, 2013

Projects

None yet

2 participants

@charris
Member
charris commented Apr 15, 2013

The next builtin has been available since Python 2.6 and allows
it.next() to be replaced by next(it). In Python 3 the next method
is gone entirely, replaced entirely by the __next__ method. The next
fixer changes all the it.next() calls to the new form and renames the
next methods to __next__. In order to keep Numpy code backwards
compatible with Python 2, a next method was readded to all the Numpy
iterators after the fixer was run so they all contain both methods. The
presence of the appropriate method could have been made version
dependent, but that looked unduly complicated.

Closes #3072.

@charris charris 2to3: Apply next fixer.
The next builtin has been available since Python 2.6 and allows
`it.next()` to be replaced by `next(it)`. In Python 3 the `next` method
is gone entirely, replaced entirely by the `__next__` method. The next
fixer changes all the `it.next()` calls to the new form and renames the
`next` methods to `__next__`. In order to keep  Numpy code backwards
compatible with Python 2, a `next` method was readded to all the Numpy
iterators after the fixer was run so they all contain both methods. The
presence of the appropriate method could have been made version
dependent, but that looked unduly complicated.

Closes #3072.
c6de097
@njsmith
Member
njsmith commented Apr 15, 2013

+1 pending Travis.

@charris
Member
charris commented Apr 15, 2013

Good, thanks.

@charris charris merged commit 9361471 into numpy:master Apr 15, 2013

1 check passed

default The Travis build passed
Details
@charris charris deleted the charris:2to3-apply-next-fixer branch Apr 15, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment