Skip to content

Commit 2e0c8ba

Browse files
committed
Python 3 preparation: use range() instead of xrange().
Tool-assisted patch. None of the existing range() uses seem to need to be wrapped in list(). Note that range() may be less efficient than xrange() in Python 2.
1 parent a8d9867 commit 2e0c8ba

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

roundup/backends/indexer_rdbms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def find(self, wordlist):
119119

120120
join_list = []
121121
match_list = []
122-
for n in xrange(len(l) - 1):
122+
for n in range(len(l) - 1):
123123
join_list.append(join_tmpl % (n + 2))
124124
match_list.append(match_tmpl % (n + 2, self.db.arg))
125125

roundup/cgi/TAL/TALGenerator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def optimize(self, program):
7979
endsep = "/>"
8080
else:
8181
endsep = " />"
82-
for cursor in xrange(len(program)+1):
82+
for cursor in range(len(program)+1):
8383
try:
8484
item = program[cursor]
8585
except IndexError:

roundup/password.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
_bjoin = _bempty.join
3434

3535
def getrandbytes(count):
36-
return _bjoin(chr(random.randint(0,255)) for i in xrange(count))
36+
return _bjoin(chr(random.randint(0,255)) for i in range(count))
3737

3838
#NOTE: PBKDF2 hash is using this variant of base64 to minimize encoding size,
3939
# and have charset that's compatible w/ unix crypt variants
@@ -69,11 +69,11 @@ def _pbkdf2(password, salt, rounds, keylen):
6969
total_blocks = int((keylen+digest_size-1)/digest_size)
7070
hmac_template = HMAC(password, None, sha1)
7171
out = _bempty
72-
for i in xrange(1, total_blocks+1):
72+
for i in range(1, total_blocks+1):
7373
hmac = hmac_template.copy()
7474
hmac.update(salt + pack(">L",i))
7575
block = tmp = hmac.digest()
76-
for j in xrange(rounds-1):
76+
for j in range(rounds-1):
7777
hmac = hmac_template.copy()
7878
hmac.update(tmp)
7979
tmp = hmac.digest()

0 commit comments

Comments
 (0)