Merge pull request #1616 from srinivasreddy/clean_up

Add six.moves.range instead of xrange
This commit is contained in:
Emmanuel Leblond 2017-08-28 13:34:17 +02:00 committed by GitHub
commit 3a5538813c
2 changed files with 5 additions and 3 deletions

View File

@ -127,7 +127,7 @@ class BaseList(list):
return value
def __iter__(self):
for i in xrange(self.__len__()):
for i in six.moves.range(self.__len__()):
yield self[i]
def __setitem__(self, key, value, *args, **kwargs):

View File

@ -1,3 +1,5 @@
import six
from mongoengine.errors import OperationError
from mongoengine.queryset.base import (BaseQuerySet, CASCADE, DENY, DO_NOTHING,
NULLIFY, PULL)
@ -112,7 +114,7 @@ class QuerySet(BaseQuerySet):
# Pull in ITER_CHUNK_SIZE docs from the database and store them in
# the result cache.
try:
for _ in xrange(ITER_CHUNK_SIZE):
for _ in six.moves.range(ITER_CHUNK_SIZE):
self._result_cache.append(self.next())
except StopIteration:
# Getting this exception means there are no more docs in the
@ -166,7 +168,7 @@ class QuerySetNoCache(BaseQuerySet):
return '.. queryset mid-iteration ..'
data = []
for _ in xrange(REPR_OUTPUT_SIZE + 1):
for _ in six.moves.range(REPR_OUTPUT_SIZE + 1):
try:
data.append(self.next())
except StopIteration: