mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
[py3] Renamed next to __next__ in iterators.
See PEP 3114. `next` is retained as an alias for Python 2.
This commit is contained in:
@@ -136,10 +136,12 @@ class Deserializer(object):
|
||||
def __iter__(self):
|
||||
return self
|
||||
|
||||
def next(self):
|
||||
def __next__(self):
|
||||
"""Iteration iterface -- return the next item in the stream"""
|
||||
raise NotImplementedError
|
||||
|
||||
next = __next__ # Python 2 compatibility
|
||||
|
||||
class DeserializedObject(object):
|
||||
"""
|
||||
A deserialized model.
|
||||
|
||||
@@ -154,13 +154,15 @@ class Deserializer(base.Deserializer):
|
||||
self.event_stream = pulldom.parse(self.stream)
|
||||
self.db = options.pop('using', DEFAULT_DB_ALIAS)
|
||||
|
||||
def next(self):
|
||||
def __next__(self):
|
||||
for event, node in self.event_stream:
|
||||
if event == "START_ELEMENT" and node.nodeName == "object":
|
||||
self.event_stream.expandNode(node)
|
||||
return self._handle_object(node)
|
||||
raise StopIteration
|
||||
|
||||
next = __next__ # Python 2 compatibility
|
||||
|
||||
def _handle_object(self, node):
|
||||
"""
|
||||
Convert an <object> node to a DeserializedObject.
|
||||
|
||||
Reference in New Issue
Block a user