Loading django/core/serializers/base.py +3 −1 Original line number Diff line number Diff line Loading @@ -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. Loading django/core/serializers/xml_serializer.py +3 −1 Original line number Diff line number Diff line Loading @@ -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. Loading django/db/backends/oracle/base.py +3 −1 Original line number Diff line number Diff line Loading @@ -774,9 +774,11 @@ class CursorIterator(object): def __iter__(self): return self def next(self): def __next__(self): return _rowfactory(next(self.iter), self.cursor) next = __next__ # Python 2 compatibility def _rowfactory(row, cursor): # Cast numeric values as the appropriate Python type based upon the Loading django/http/__init__.py +3 −1 Original line number Diff line number Diff line Loading @@ -669,12 +669,14 @@ class HttpResponse(object): self._iterator = iter(self._container) return self def next(self): def __next__(self): chunk = next(self._iterator) if isinstance(chunk, six.text_type): chunk = chunk.encode(self._charset) return str(chunk) next = __next__ # Python 2 compatibility def close(self): if hasattr(self._container, 'close'): self._container.close() Loading django/http/multipartparser.py +12 −4 Original line number Diff line number Diff line Loading @@ -305,7 +305,7 @@ class LazyStream(object): out = b''.join(parts()) return out def next(self): def __next__(self): """ Used when the exact number of bytes to read is unimportant. Loading @@ -322,6 +322,8 @@ class LazyStream(object): self.position += len(output) return output next = __next__ # Python 2 compatibility def close(self): """ Used to invalidate/disable this lazy stream. Loading Loading @@ -376,7 +378,7 @@ class ChunkIter(object): self.flo = flo self.chunk_size = chunk_size def next(self): def __next__(self): try: data = self.flo.read(self.chunk_size) except InputStreamExhausted: Loading @@ -386,6 +388,8 @@ class ChunkIter(object): else: raise StopIteration() next = __next__ # Python 2 compatibility def __iter__(self): return self Loading @@ -400,12 +404,14 @@ class InterBoundaryIter(object): def __iter__(self): return self def next(self): def __next__(self): try: return LazyStream(BoundaryIter(self._stream, self._boundary)) except InputStreamExhausted: raise StopIteration() next = __next__ # Python 2 compatibility class BoundaryIter(object): """ A Producer that is sensitive to boundaries. Loading Loading @@ -441,7 +447,7 @@ class BoundaryIter(object): def __iter__(self): return self def next(self): def __next__(self): if self._done: raise StopIteration() Loading Loading @@ -482,6 +488,8 @@ class BoundaryIter(object): stream.unget(chunk[-rollback:]) return chunk[:-rollback] next = __next__ # Python 2 compatibility def _find_boundary(self, data, eof = False): """ Finds a multipart boundary in data. Loading Loading
django/core/serializers/base.py +3 −1 Original line number Diff line number Diff line Loading @@ -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. Loading
django/core/serializers/xml_serializer.py +3 −1 Original line number Diff line number Diff line Loading @@ -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. Loading
django/db/backends/oracle/base.py +3 −1 Original line number Diff line number Diff line Loading @@ -774,9 +774,11 @@ class CursorIterator(object): def __iter__(self): return self def next(self): def __next__(self): return _rowfactory(next(self.iter), self.cursor) next = __next__ # Python 2 compatibility def _rowfactory(row, cursor): # Cast numeric values as the appropriate Python type based upon the Loading
django/http/__init__.py +3 −1 Original line number Diff line number Diff line Loading @@ -669,12 +669,14 @@ class HttpResponse(object): self._iterator = iter(self._container) return self def next(self): def __next__(self): chunk = next(self._iterator) if isinstance(chunk, six.text_type): chunk = chunk.encode(self._charset) return str(chunk) next = __next__ # Python 2 compatibility def close(self): if hasattr(self._container, 'close'): self._container.close() Loading
django/http/multipartparser.py +12 −4 Original line number Diff line number Diff line Loading @@ -305,7 +305,7 @@ class LazyStream(object): out = b''.join(parts()) return out def next(self): def __next__(self): """ Used when the exact number of bytes to read is unimportant. Loading @@ -322,6 +322,8 @@ class LazyStream(object): self.position += len(output) return output next = __next__ # Python 2 compatibility def close(self): """ Used to invalidate/disable this lazy stream. Loading Loading @@ -376,7 +378,7 @@ class ChunkIter(object): self.flo = flo self.chunk_size = chunk_size def next(self): def __next__(self): try: data = self.flo.read(self.chunk_size) except InputStreamExhausted: Loading @@ -386,6 +388,8 @@ class ChunkIter(object): else: raise StopIteration() next = __next__ # Python 2 compatibility def __iter__(self): return self Loading @@ -400,12 +404,14 @@ class InterBoundaryIter(object): def __iter__(self): return self def next(self): def __next__(self): try: return LazyStream(BoundaryIter(self._stream, self._boundary)) except InputStreamExhausted: raise StopIteration() next = __next__ # Python 2 compatibility class BoundaryIter(object): """ A Producer that is sensitive to boundaries. Loading Loading @@ -441,7 +447,7 @@ class BoundaryIter(object): def __iter__(self): return self def next(self): def __next__(self): if self._done: raise StopIteration() Loading Loading @@ -482,6 +488,8 @@ class BoundaryIter(object): stream.unget(chunk[-rollback:]) return chunk[:-rollback] next = __next__ # Python 2 compatibility def _find_boundary(self, data, eof = False): """ Finds a multipart boundary in data. Loading