Skip to content

Commit 169b1a4

Browse files
committed
Replaced foo.next() by next(foo).
This new syntax for next() has been introduced in Python 2.6 and is compatible with Python 3.
1 parent 1c1a229 commit 169b1a4

File tree

20 files changed

+73
-73
lines changed

20 files changed

+73
-73
lines changed

django/contrib/admin/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def first_field(self):
5353
except (KeyError, IndexError):
5454
pass
5555
try:
56-
return iter(self.form).next()
56+
return next(iter(self.form))
5757
except StopIteration:
5858
return None
5959

django/contrib/gis/geos/point.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ def _create_point(self, ndim, coords):
4646

4747
cs = capi.create_cs(c_uint(1), c_uint(ndim))
4848
i = iter(coords)
49-
capi.cs_setx(cs, 0, i.next())
50-
capi.cs_sety(cs, 0, i.next())
51-
if ndim == 3: capi.cs_setz(cs, 0, i.next())
49+
capi.cs_setx(cs, 0, next(i))
50+
capi.cs_sety(cs, 0, next(i))
51+
if ndim == 3: capi.cs_setz(cs, 0, next(i))
5252

5353
return capi.create_point(cs)
5454

django/contrib/localflavor/ro/forms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def clean(self, value):
3939
key_iter = iter(key)
4040
checksum = 0
4141
for digit in value[1:]:
42-
checksum += int(digit) * int(key_iter.next())
42+
checksum += int(digit) * int(next(key_iter))
4343
checksum = checksum * 10 % 11
4444
if checksum == 10:
4545
checksum = 0
@@ -79,7 +79,7 @@ def clean(self, value):
7979
checksum = 0
8080
value_iter = iter(value)
8181
for digit in key:
82-
checksum += int(digit) * int(value_iter.next())
82+
checksum += int(digit) * int(next(value_iter))
8383
checksum %= 11
8484
if checksum == 10:
8585
checksum = 1

django/core/files/storage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def get_available_name(self, name):
6969
count = itertools.count(1)
7070
while self.exists(name):
7171
# file_ext includes the dot.
72-
name = os.path.join(dir_name, "%s_%s%s" % (file_root, count.next(), file_ext))
72+
name = os.path.join(dir_name, "%s_%s%s" % (file_root, next(count), file_ext))
7373

7474
return name
7575

django/db/backends/oracle/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ def __iter__(self):
754754
return self
755755

756756
def next(self):
757-
return _rowfactory(self.iter.next(), self.cursor)
757+
return _rowfactory(next(self.iter), self.cursor)
758758

759759

760760
def _rowfactory(row, cursor):

django/db/models/query.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def __nonzero__(self):
128128
if self._result_cache is not None:
129129
return bool(self._result_cache)
130130
try:
131-
iter(self).next()
131+
next(iter(self))
132132
except StopIteration:
133133
return False
134134
return True
@@ -877,7 +877,7 @@ def _fill_cache(self, num=None):
877877
if self._iter:
878878
try:
879879
for i in range(num or ITER_CHUNK_SIZE):
880-
self._result_cache.append(self._iter.next())
880+
self._result_cache.append(next(self._iter))
881881
except StopIteration:
882882
self._iter = None
883883

@@ -1147,7 +1147,7 @@ def _clone(self, klass=None, setup=False, **kwargs):
11471147
def iterator(self):
11481148
# This slightly odd construction is because we need an empty generator
11491149
# (it raises StopIteration immediately).
1150-
yield iter([]).next()
1150+
yield next(iter([]))
11511151

11521152
def all(self):
11531153
"""

django/db/models/sql/compiler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,7 @@ def empty_iter():
10821082
"""
10831083
Returns an iterator containing no results.
10841084
"""
1085-
yield iter([]).next()
1085+
yield next(iter([]))
10861086

10871087

10881088
def order_modified_iter(cursor, trim, sentinel):

django/db/models/sql/query.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,10 +1140,10 @@ def add_filter(self, filter_expr, connector=AND, negate=False, trim=False,
11401140
# join list) an outer join.
11411141
join_it = iter(join_list)
11421142
table_it = iter(self.tables)
1143-
join_it.next(), table_it.next()
1143+
next(join_it), next(table_it)
11441144
unconditional = False
11451145
for join in join_it:
1146-
table = table_it.next()
1146+
table = next(table_it)
11471147
# Once we hit an outer join, all subsequent joins must
11481148
# also be promoted, regardless of whether they have been
11491149
# promoted as a result of this pass through the tables.
@@ -1774,7 +1774,7 @@ def add_extra(self, select, select_params, where, params, tables, order_by):
17741774
entry_params = []
17751775
pos = entry.find("%s")
17761776
while pos != -1:
1777-
entry_params.append(param_iter.next())
1777+
entry_params.append(next(param_iter))
17781778
pos = entry.find("%s", pos + 2)
17791779
select_pairs[name] = (entry, entry_params)
17801780
# This is order preserving, since self.extra_select is a SortedDict.

django/http/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ def __iter__(self):
668668
return self
669669

670670
def next(self):
671-
chunk = self._iterator.next()
671+
chunk = next(self._iterator)
672672
if isinstance(chunk, unicode):
673673
chunk = chunk.encode(self._charset)
674674
return str(chunk)

django/http/multipartparser.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ def parts():
291291
while remaining != 0:
292292
assert remaining > 0, 'remaining bytes to read should never go negative'
293293

294-
chunk = self.next()
294+
chunk = next(self)
295295

296296
emitting = chunk[:remaining]
297297
self.unget(chunk[remaining:])
@@ -313,7 +313,7 @@ def next(self):
313313
output = self._leftover
314314
self._leftover = ''
315315
else:
316-
output = self._producer.next()
316+
output = next(self._producer)
317317
self._unget_history = []
318318
self.position += len(output)
319319
return output
@@ -410,7 +410,7 @@ class BoundaryIter(object):
410410
before the boundary, throw away the boundary bytes themselves, and push the
411411
post-boundary bytes back on the stream.
412412
413-
The future calls to .next() after locating the boundary will raise a
413+
The future calls to next() after locating the boundary will raise a
414414
StopIteration exception.
415415
"""
416416

0 commit comments

Comments
 (0)