Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Replaced foo.next() by next(foo).

This new syntax for next() has been introduced in Python 2.6 and is
compatible with Python 3.
  • Loading branch information...
commit 169b1a404c8118bb75840523d5fb3543de9c8889 1 parent 1c1a229
Claude Paroz authored May 10, 2012
2  django/contrib/admin/helpers.py
@@ -53,7 +53,7 @@ def first_field(self):
53 53
         except (KeyError, IndexError):
54 54
             pass
55 55
         try:
56  
-            return iter(self.form).next()
  56
+            return next(iter(self.form))
57 57
         except StopIteration:
58 58
             return None
59 59
 
6  django/contrib/gis/geos/point.py
@@ -46,9 +46,9 @@ def _create_point(self, ndim, coords):
46 46
 
47 47
         cs = capi.create_cs(c_uint(1), c_uint(ndim))
48 48
         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))
52 52
 
53 53
         return capi.create_point(cs)
54 54
 
4  django/contrib/localflavor/ro/forms.py
@@ -39,7 +39,7 @@ def clean(self, value):
39 39
         key_iter = iter(key)
40 40
         checksum = 0
41 41
         for digit in value[1:]:
42  
-            checksum += int(digit) * int(key_iter.next())
  42
+            checksum += int(digit) * int(next(key_iter))
43 43
         checksum = checksum * 10 % 11
44 44
         if checksum == 10:
45 45
             checksum = 0
@@ -79,7 +79,7 @@ def clean(self, value):
79 79
         checksum = 0
80 80
         value_iter = iter(value)
81 81
         for digit in key:
82  
-            checksum += int(digit) * int(value_iter.next())
  82
+            checksum += int(digit) * int(next(value_iter))
83 83
         checksum %= 11
84 84
         if checksum == 10:
85 85
             checksum = 1
2  django/core/files/storage.py
@@ -69,7 +69,7 @@ def get_available_name(self, name):
69 69
         count = itertools.count(1)
70 70
         while self.exists(name):
71 71
             # 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))
73 73
 
74 74
         return name
75 75
 
2  django/db/backends/oracle/base.py
@@ -754,7 +754,7 @@ def __iter__(self):
754 754
         return self
755 755
 
756 756
     def next(self):
757  
-        return _rowfactory(self.iter.next(), self.cursor)
  757
+        return _rowfactory(next(self.iter), self.cursor)
758 758
 
759 759
 
760 760
 def _rowfactory(row, cursor):
6  django/db/models/query.py
@@ -128,7 +128,7 @@ def __nonzero__(self):
128 128
         if self._result_cache is not None:
129 129
             return bool(self._result_cache)
130 130
         try:
131  
-            iter(self).next()
  131
+            next(iter(self))
132 132
         except StopIteration:
133 133
             return False
134 134
         return True
@@ -877,7 +877,7 @@ def _fill_cache(self, num=None):
877 877
         if self._iter:
878 878
             try:
879 879
                 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))
881 881
             except StopIteration:
882 882
                 self._iter = None
883 883
 
@@ -1147,7 +1147,7 @@ def _clone(self, klass=None, setup=False, **kwargs):
1147 1147
     def iterator(self):
1148 1148
         # This slightly odd construction is because we need an empty generator
1149 1149
         # (it raises StopIteration immediately).
1150  
-        yield iter([]).next()
  1150
+        yield next(iter([]))
1151 1151
 
1152 1152
     def all(self):
1153 1153
         """
2  django/db/models/sql/compiler.py
@@ -1082,7 +1082,7 @@ def empty_iter():
1082 1082
     """
1083 1083
     Returns an iterator containing no results.
1084 1084
     """
1085  
-    yield iter([]).next()
  1085
+    yield next(iter([]))
1086 1086
 
1087 1087
 
1088 1088
 def order_modified_iter(cursor, trim, sentinel):
6  django/db/models/sql/query.py
@@ -1140,10 +1140,10 @@ def add_filter(self, filter_expr, connector=AND, negate=False, trim=False,
1140 1140
             # join list) an outer join.
1141 1141
             join_it = iter(join_list)
1142 1142
             table_it = iter(self.tables)
1143  
-            join_it.next(), table_it.next()
  1143
+            next(join_it), next(table_it)
1144 1144
             unconditional = False
1145 1145
             for join in join_it:
1146  
-                table = table_it.next()
  1146
+                table = next(table_it)
1147 1147
                 # Once we hit an outer join, all subsequent joins must
1148 1148
                 # also be promoted, regardless of whether they have been
1149 1149
                 # 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):
1774 1774
                 entry_params = []
1775 1775
                 pos = entry.find("%s")
1776 1776
                 while pos != -1:
1777  
-                    entry_params.append(param_iter.next())
  1777
+                    entry_params.append(next(param_iter))
1778 1778
                     pos = entry.find("%s", pos + 2)
1779 1779
                 select_pairs[name] = (entry, entry_params)
1780 1780
             # This is order preserving, since self.extra_select is a SortedDict.
2  django/http/__init__.py
@@ -668,7 +668,7 @@ def __iter__(self):
668 668
         return self
669 669
 
670 670
     def next(self):
671  
-        chunk = self._iterator.next()
  671
+        chunk = next(self._iterator)
672 672
         if isinstance(chunk, unicode):
673 673
             chunk = chunk.encode(self._charset)
674 674
         return str(chunk)
6  django/http/multipartparser.py
@@ -291,7 +291,7 @@ def parts():
291 291
             while remaining != 0:
292 292
                 assert remaining > 0, 'remaining bytes to read should never go negative'
293 293
 
294  
-                chunk = self.next()
  294
+                chunk = next(self)
295 295
 
296 296
                 emitting = chunk[:remaining]
297 297
                 self.unget(chunk[remaining:])
@@ -313,7 +313,7 @@ def next(self):
313 313
             output = self._leftover
314 314
             self._leftover = ''
315 315
         else:
316  
-            output = self._producer.next()
  316
+            output = next(self._producer)
317 317
             self._unget_history = []
318 318
         self.position += len(output)
319 319
         return output
@@ -410,7 +410,7 @@ class BoundaryIter(object):
410 410
     before the boundary, throw away the boundary bytes themselves, and push the
411 411
     post-boundary bytes back on the stream.
412 412
 
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
414 414
     StopIteration exception.
415 415
     """
416 416
 
2  django/template/base.py
@@ -173,7 +173,7 @@ def split_contents(self):
173 173
                 sentinal = bit[2] + ')'
174 174
                 trans_bit = [bit]
175 175
                 while not bit.endswith(sentinal):
176  
-                    bit = bits.next()
  176
+                    bit = next(bits)
177 177
                     trans_bit.append(bit)
178 178
                 bit = ' '.join(trans_bit)
179 179
             split.append(bit)
2  django/template/defaulttags.py
@@ -66,7 +66,7 @@ def render(self, context):
66 66
             # First time the node is rendered in template
67 67
             context.render_context[self] = itertools_cycle(self.cyclevars)
68 68
         cycle_iter = context.render_context[self]
69  
-        value = cycle_iter.next().resolve(context)
  69
+        value = next(cycle_iter).resolve(context)
70 70
         if self.variable_name:
71 71
             context[self.variable_name] = value
72 72
         if self.silent:
6  django/template/smartif.py
@@ -165,7 +165,7 @@ def __init__(self, tokens):
165 165
 
166 166
         self.tokens = mapped_tokens
167 167
         self.pos = 0
168  
-        self.current_token = self.next()
  168
+        self.current_token = next(self)
169 169
 
170 170
     def translate_token(self, token):
171 171
         try:
@@ -193,11 +193,11 @@ def parse(self):
193 193
 
194 194
     def expression(self, rbp=0):
195 195
         t = self.current_token
196  
-        self.current_token = self.next()
  196
+        self.current_token = next(self)
197 197
         left = t.nud(self)
198 198
         while rbp < self.current_token.lbp:
199 199
             t = self.current_token
200  
-            self.current_token = self.next()
  200
+            self.current_token = next(self)
201 201
             left = t.led(left, self)
202 202
         return left
203 203
 
28  django/utils/regex_helper.py
@@ -75,7 +75,7 @@ def normalize(pattern):
75 75
     # at the next character and possibly go around without consuming another
76 76
     # one at the top of the loop.
77 77
     try:
78  
-        ch, escaped = pattern_iter.next()
  78
+        ch, escaped = next(pattern_iter)
79 79
     except StopIteration:
80 80
         return zip([u''],  [[]])
81 81
 
@@ -105,14 +105,14 @@ def normalize(pattern):
105 105
                 result = result[:start] + [inner]
106 106
             elif ch == '[':
107 107
                 # Replace ranges with the first character in the range.
108  
-                ch, escaped = pattern_iter.next()
  108
+                ch, escaped = next(pattern_iter)
109 109
                 result.append(ch)
110  
-                ch, escaped = pattern_iter.next()
  110
+                ch, escaped = next(pattern_iter)
111 111
                 while escaped or ch != ']':
112  
-                    ch, escaped = pattern_iter.next()
  112
+                    ch, escaped = next(pattern_iter)
113 113
             elif ch == '(':
114 114
                 # Some kind of group.
115  
-                ch, escaped = pattern_iter.next()
  115
+                ch, escaped = next(pattern_iter)
116 116
                 if ch != '?' or escaped:
117 117
                     # A positional group
118 118
                     name = "_%d" % num_args
@@ -120,7 +120,7 @@ def normalize(pattern):
120 120
                     result.append(Group(((u"%%(%s)s" % name), name)))
121 121
                     walk_to_end(ch, pattern_iter)
122 122
                 else:
123  
-                    ch, escaped = pattern_iter.next()
  123
+                    ch, escaped = next(pattern_iter)
124 124
                     if ch in "iLmsu#":
125 125
                         # All of these are ignorable. Walk to the end of the
126 126
                         # group.
@@ -133,7 +133,7 @@ def normalize(pattern):
133 133
                         # we cannot reverse.
134 134
                         raise ValueError("Non-reversible reg-exp portion: '(?%s'" % ch)
135 135
                     else:
136  
-                        ch, escaped = pattern_iter.next()
  136
+                        ch, escaped = next(pattern_iter)
137 137
                         if ch not in ('<', '='):
138 138
                             raise ValueError("Non-reversible reg-exp portion: '(?P%s'" % ch)
139 139
                         # We are in a named capturing group. Extra the name and
@@ -144,10 +144,10 @@ def normalize(pattern):
144 144
                         else:
145 145
                             terminal_char = ')'
146 146
                         name = []
147  
-                        ch, escaped = pattern_iter.next()
  147
+                        ch, escaped = next(pattern_iter)
148 148
                         while ch != terminal_char:
149 149
                             name.append(ch)
150  
-                            ch, escaped = pattern_iter.next()
  150
+                            ch, escaped = next(pattern_iter)
151 151
                         param = ''.join(name)
152 152
                         # Named backreferences have already consumed the
153 153
                         # parenthesis.
@@ -183,7 +183,7 @@ def normalize(pattern):
183 183
                 result.append(ch)
184 184
 
185 185
             if consume_next:
186  
-                ch, escaped = pattern_iter.next()
  186
+                ch, escaped = next(pattern_iter)
187 187
             else:
188 188
                 consume_next = True
189 189
     except StopIteration:
@@ -208,7 +208,7 @@ def next_char(input_iter):
208 208
         if ch != '\\':
209 209
             yield ch, False
210 210
             continue
211  
-        ch = input_iter.next()
  211
+        ch = next(input_iter)
212 212
         representative = ESCAPE_MAPPINGS.get(ch, ch)
213 213
         if representative is None:
214 214
             continue
@@ -245,7 +245,7 @@ def get_quantifier(ch, input_iter):
245 245
     """
246 246
     if ch in '*?+':
247 247
         try:
248  
-            ch2, escaped = input_iter.next()
  248
+            ch2, escaped = next(input_iter)
249 249
         except StopIteration:
250 250
             ch2 = None
251 251
         if ch2 == '?':
@@ -256,14 +256,14 @@ def get_quantifier(ch, input_iter):
256 256
 
257 257
     quant = []
258 258
     while ch != '}':
259  
-        ch, escaped = input_iter.next()
  259
+        ch, escaped = next(input_iter)
260 260
         quant.append(ch)
261 261
     quant = quant[:-1]
262 262
     values = ''.join(quant).split(',')
263 263
 
264 264
     # Consume the trailing '?', if necessary.
265 265
     try:
266  
-        ch, escaped = input_iter.next()
  266
+        ch, escaped = next(input_iter)
267 267
     except StopIteration:
268 268
         ch = None
269 269
     if ch == '?':
2  django/utils/text.py
@@ -26,7 +26,7 @@ def wrap(text, width):
26 26
     text = force_unicode(text)
27 27
     def _generator():
28 28
         it = iter(text.split(' '))
29  
-        word = it.next()
  29
+        word = next(it)
30 30
         yield word
31 31
         pos = len(word) - word.rfind('\n') - 1
32 32
         for word in it:
4  docs/howto/custom-template-tags.txt
@@ -569,7 +569,7 @@ A naive implementation of ``CycleNode`` might look something like this:
569 569
         def __init__(self, cyclevars):
570 570
             self.cycle_iter = itertools.cycle(cyclevars)
571 571
         def render(self, context):
572  
-            return self.cycle_iter.next()
  572
+            return next(self.cycle_iter)
573 573
 
574 574
 But, suppose we have two templates rendering the template snippet from above at
575 575
 the same time:
@@ -603,7 +603,7 @@ Let's refactor our ``CycleNode`` implementation to use the ``render_context``:
603 603
             if self not in context.render_context:
604 604
                 context.render_context[self] = itertools.cycle(self.cyclevars)
605 605
             cycle_iter = context.render_context[self]
606  
-            return cycle_iter.next()
  606
+            return next(cycle_iter)
607 607
 
608 608
 Note that it's perfectly safe to store global information that will not change
609 609
 throughout the life of the ``Node`` as an attribute. In the case of
48  tests/modeltests/timezones/tests.py
@@ -493,23 +493,23 @@ def test_naive_datetime(self):
493 493
 
494 494
         data = serializers.serialize('python', [Event(dt=dt)])
495 495
         self.assertEqual(data[0]['fields']['dt'], dt)
496  
-        obj = serializers.deserialize('python', data).next().object
  496
+        obj = next(serializers.deserialize('python', data)).object
497 497
         self.assertEqual(obj.dt, dt)
498 498
 
499 499
         data = serializers.serialize('json', [Event(dt=dt)])
500 500
         self.assertIn('"fields": {"dt": "2011-09-01T13:20:30"}', data)
501  
-        obj = serializers.deserialize('json', data).next().object
  501
+        obj = next(serializers.deserialize('json', data)).object
502 502
         self.assertEqual(obj.dt, dt)
503 503
 
504 504
         data = serializers.serialize('xml', [Event(dt=dt)])
505 505
         self.assertIn('<field type="DateTimeField" name="dt">2011-09-01T13:20:30</field>', data)
506  
-        obj = serializers.deserialize('xml', data).next().object
  506
+        obj = next(serializers.deserialize('xml', data)).object
507 507
         self.assertEqual(obj.dt, dt)
508 508
 
509 509
         if 'yaml' in serializers.get_serializer_formats():
510 510
             data = serializers.serialize('yaml', [Event(dt=dt)])
511 511
             self.assertIn("- fields: {dt: !!timestamp '2011-09-01 13:20:30'}", data)
512  
-            obj = serializers.deserialize('yaml', data).next().object
  512
+            obj = next(serializers.deserialize('yaml', data)).object
513 513
             self.assertEqual(obj.dt, dt)
514 514
 
515 515
     def test_naive_datetime_with_microsecond(self):
@@ -517,23 +517,23 @@ def test_naive_datetime_with_microsecond(self):
517 517
 
518 518
         data = serializers.serialize('python', [Event(dt=dt)])
519 519
         self.assertEqual(data[0]['fields']['dt'], dt)
520  
-        obj = serializers.deserialize('python', data).next().object
  520
+        obj = next(serializers.deserialize('python', data)).object
521 521
         self.assertEqual(obj.dt, dt)
522 522
 
523 523
         data = serializers.serialize('json', [Event(dt=dt)])
524 524
         self.assertIn('"fields": {"dt": "2011-09-01T13:20:30.405"}', data)
525  
-        obj = serializers.deserialize('json', data).next().object
  525
+        obj = next(serializers.deserialize('json', data)).object
526 526
         self.assertEqual(obj.dt, dt.replace(microsecond=405000))
527 527
 
528 528
         data = serializers.serialize('xml', [Event(dt=dt)])
529 529
         self.assertIn('<field type="DateTimeField" name="dt">2011-09-01T13:20:30.405060</field>', data)
530  
-        obj = serializers.deserialize('xml', data).next().object
  530
+        obj = next(serializers.deserialize('xml', data)).object
531 531
         self.assertEqual(obj.dt, dt)
532 532
 
533 533
         if 'yaml' in serializers.get_serializer_formats():
534 534
             data = serializers.serialize('yaml', [Event(dt=dt)])
535 535
             self.assertIn("- fields: {dt: !!timestamp '2011-09-01 13:20:30.405060'}", data)
536  
-            obj = serializers.deserialize('yaml', data).next().object
  536
+            obj = next(serializers.deserialize('yaml', data)).object
537 537
             self.assertEqual(obj.dt, dt)
538 538
 
539 539
     def test_aware_datetime_with_microsecond(self):
@@ -541,23 +541,23 @@ def test_aware_datetime_with_microsecond(self):
541 541
 
542 542
         data = serializers.serialize('python', [Event(dt=dt)])
543 543
         self.assertEqual(data[0]['fields']['dt'], dt)
544  
-        obj = serializers.deserialize('python', data).next().object
  544
+        obj = next(serializers.deserialize('python', data)).object
545 545
         self.assertEqual(obj.dt, dt)
546 546
 
547 547
         data = serializers.serialize('json', [Event(dt=dt)])
548 548
         self.assertIn('"fields": {"dt": "2011-09-01T17:20:30.405+07:00"}', data)
549  
-        obj = serializers.deserialize('json', data).next().object
  549
+        obj = next(serializers.deserialize('json', data)).object
550 550
         self.assertEqual(obj.dt, dt.replace(microsecond=405000))
551 551
 
552 552
         data = serializers.serialize('xml', [Event(dt=dt)])
553 553
         self.assertIn('<field type="DateTimeField" name="dt">2011-09-01T17:20:30.405060+07:00</field>', data)
554  
-        obj = serializers.deserialize('xml', data).next().object
  554
+        obj = next(serializers.deserialize('xml', data)).object
555 555
         self.assertEqual(obj.dt, dt)
556 556
 
557 557
         if 'yaml' in serializers.get_serializer_formats():
558 558
             data = serializers.serialize('yaml', [Event(dt=dt)])
559 559
             self.assertIn("- fields: {dt: !!timestamp '2011-09-01 17:20:30.405060+07:00'}", data)
560  
-            obj = serializers.deserialize('yaml', data).next().object
  560
+            obj = next(serializers.deserialize('yaml', data)).object
561 561
             self.assertEqual(obj.dt.replace(tzinfo=UTC), dt)
562 562
 
563 563
     def test_aware_datetime_in_utc(self):
@@ -565,23 +565,23 @@ def test_aware_datetime_in_utc(self):
565 565
 
566 566
         data = serializers.serialize('python', [Event(dt=dt)])
567 567
         self.assertEqual(data[0]['fields']['dt'], dt)
568  
-        obj = serializers.deserialize('python', data).next().object
  568
+        obj = next(serializers.deserialize('python', data)).object
569 569
         self.assertEqual(obj.dt, dt)
570 570
 
571 571
         data = serializers.serialize('json', [Event(dt=dt)])
572 572
         self.assertIn('"fields": {"dt": "2011-09-01T10:20:30Z"}', data)
573  
-        obj = serializers.deserialize('json', data).next().object
  573
+        obj = next(serializers.deserialize('json', data)).object
574 574
         self.assertEqual(obj.dt, dt)
575 575
 
576 576
         data = serializers.serialize('xml', [Event(dt=dt)])
577 577
         self.assertIn('<field type="DateTimeField" name="dt">2011-09-01T10:20:30+00:00</field>', data)
578  
-        obj = serializers.deserialize('xml', data).next().object
  578
+        obj = next(serializers.deserialize('xml', data)).object
579 579
         self.assertEqual(obj.dt, dt)
580 580
 
581 581
         if 'yaml' in serializers.get_serializer_formats():
582 582
             data = serializers.serialize('yaml', [Event(dt=dt)])
583 583
             self.assertIn("- fields: {dt: !!timestamp '2011-09-01 10:20:30+00:00'}", data)
584  
-            obj = serializers.deserialize('yaml', data).next().object
  584
+            obj = next(serializers.deserialize('yaml', data)).object
585 585
             self.assertEqual(obj.dt.replace(tzinfo=UTC), dt)
586 586
 
587 587
     def test_aware_datetime_in_local_timezone(self):
@@ -589,23 +589,23 @@ def test_aware_datetime_in_local_timezone(self):
589 589
 
590 590
         data = serializers.serialize('python', [Event(dt=dt)])
591 591
         self.assertEqual(data[0]['fields']['dt'], dt)
592  
-        obj = serializers.deserialize('python', data).next().object
  592
+        obj = next(serializers.deserialize('python', data)).object
593 593
         self.assertEqual(obj.dt, dt)
594 594
 
595 595
         data = serializers.serialize('json', [Event(dt=dt)])
596 596
         self.assertIn('"fields": {"dt": "2011-09-01T13:20:30+03:00"}', data)
597  
-        obj = serializers.deserialize('json', data).next().object
  597
+        obj = next(serializers.deserialize('json', data)).object
598 598
         self.assertEqual(obj.dt, dt)
599 599
 
600 600
         data = serializers.serialize('xml', [Event(dt=dt)])
601 601
         self.assertIn('<field type="DateTimeField" name="dt">2011-09-01T13:20:30+03:00</field>', data)
602  
-        obj = serializers.deserialize('xml', data).next().object
  602
+        obj = next(serializers.deserialize('xml', data)).object
603 603
         self.assertEqual(obj.dt, dt)
604 604
 
605 605
         if 'yaml' in serializers.get_serializer_formats():
606 606
             data = serializers.serialize('yaml', [Event(dt=dt)])
607 607
             self.assertIn("- fields: {dt: !!timestamp '2011-09-01 13:20:30+03:00'}", data)
608  
-            obj = serializers.deserialize('yaml', data).next().object
  608
+            obj = next(serializers.deserialize('yaml', data)).object
609 609
             self.assertEqual(obj.dt.replace(tzinfo=UTC), dt)
610 610
 
611 611
     def test_aware_datetime_in_other_timezone(self):
@@ -613,23 +613,23 @@ def test_aware_datetime_in_other_timezone(self):
613 613
 
614 614
         data = serializers.serialize('python', [Event(dt=dt)])
615 615
         self.assertEqual(data[0]['fields']['dt'], dt)
616  
-        obj = serializers.deserialize('python', data).next().object
  616
+        obj = next(serializers.deserialize('python', data)).object
617 617
         self.assertEqual(obj.dt, dt)
618 618
 
619 619
         data = serializers.serialize('json', [Event(dt=dt)])
620 620
         self.assertIn('"fields": {"dt": "2011-09-01T17:20:30+07:00"}', data)
621  
-        obj = serializers.deserialize('json', data).next().object
  621
+        obj = next(serializers.deserialize('json', data)).object
622 622
         self.assertEqual(obj.dt, dt)
623 623
 
624 624
         data = serializers.serialize('xml', [Event(dt=dt)])
625 625
         self.assertIn('<field type="DateTimeField" name="dt">2011-09-01T17:20:30+07:00</field>', data)
626  
-        obj = serializers.deserialize('xml', data).next().object
  626
+        obj = next(serializers.deserialize('xml', data)).object
627 627
         self.assertEqual(obj.dt, dt)
628 628
 
629 629
         if 'yaml' in serializers.get_serializer_formats():
630 630
             data = serializers.serialize('yaml', [Event(dt=dt)])
631 631
             self.assertIn("- fields: {dt: !!timestamp '2011-09-01 17:20:30+07:00'}", data)
632  
-            obj = serializers.deserialize('yaml', data).next().object
  632
+            obj = next(serializers.deserialize('yaml', data)).object
633 633
             self.assertEqual(obj.dt.replace(tzinfo=UTC), dt)
634 634
 
635 635
 
2  tests/regressiontests/httpwrappers/tests.py
@@ -281,7 +281,7 @@ def test_iter_content(self):
281 281
         my_iter = r.__iter__()
282 282
         while True:
283 283
             try:
284  
-                result.append(my_iter.next())
  284
+                result.append(next(my_iter))
285 285
             except StopIteration:
286 286
                 break
287 287
         #'\xde\x9e' == unichr(1950).encode('utf-8')
12  tests/regressiontests/queries/tests.py
@@ -1398,12 +1398,12 @@ def test_parallel_iterators(self):
1398 1398
         # Test that parallel iterators work.
1399 1399
         qs = Tag.objects.all()
1400 1400
         i1, i2 = iter(qs), iter(qs)
1401  
-        self.assertEqual(repr(i1.next()), '<Tag: t1>')
1402  
-        self.assertEqual(repr(i1.next()), '<Tag: t2>')
1403  
-        self.assertEqual(repr(i2.next()), '<Tag: t1>')
1404  
-        self.assertEqual(repr(i2.next()), '<Tag: t2>')
1405  
-        self.assertEqual(repr(i2.next()), '<Tag: t3>')
1406  
-        self.assertEqual(repr(i1.next()), '<Tag: t3>')
  1401
+        self.assertEqual(repr(next(i1)), '<Tag: t1>')
  1402
+        self.assertEqual(repr(next(i1)), '<Tag: t2>')
  1403
+        self.assertEqual(repr(next(i2)), '<Tag: t1>')
  1404
+        self.assertEqual(repr(next(i2)), '<Tag: t2>')
  1405
+        self.assertEqual(repr(next(i2)), '<Tag: t3>')
  1406
+        self.assertEqual(repr(next(i1)), '<Tag: t3>')
1407 1407
 
1408 1408
         qs = X.objects.all()
1409 1409
         self.assertEqual(bool(qs), False)
2  tests/regressiontests/serializers_regress/tests.py
@@ -489,7 +489,7 @@ def fieldsTest(format, self):
489 489
 
490 490
     # Serialize then deserialize the test database
491 491
     serialized_data = serializers.serialize(format, [obj], indent=2, fields=('field1','field3'))
492  
-    result = serializers.deserialize(format, serialized_data).next()
  492
+    result = next(serializers.deserialize(format, serialized_data))
493 493
 
494 494
     # Check that the deserialized object contains data in only the serialized fields.
495 495
     self.assertEqual(result.object.field1, 'first')

0 notes on commit 169b1a4

Please sign in to comment.
Something went wrong with that request. Please try again.