mirror of
https://github.com/django/django.git
synced 2025-10-30 17:16:10 +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:
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
@@ -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:
|
||||
@@ -386,6 +388,8 @@ class ChunkIter(object):
|
||||
else:
|
||||
raise StopIteration()
|
||||
|
||||
next = __next__ # Python 2 compatibility
|
||||
|
||||
def __iter__(self):
|
||||
return self
|
||||
|
||||
@@ -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.
|
||||
@@ -441,7 +447,7 @@ class BoundaryIter(object):
|
||||
def __iter__(self):
|
||||
return self
|
||||
|
||||
def next(self):
|
||||
def __next__(self):
|
||||
if self._done:
|
||||
raise StopIteration()
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user