From 4eb697b7def1424d43ea6b22461afed70dfe661b Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Fri, 13 Jul 2012 13:20:09 +0000 Subject: [PATCH] Use range instead of xrange * lib/mudpy/password.py: Python 3000 is deprecating xrange in favor of an iterator-based range which will be effectively as efficient, so stop using xrange in preparation for the transition. --- lib/mudpy/password.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/mudpy/password.py b/lib/mudpy/password.py index 20615b9..56bdbfe 100644 --- a/lib/mudpy/password.py +++ b/lib/mudpy/password.py @@ -55,7 +55,7 @@ def _generate_salt(salt_len=2): import math import random salt = [] - for i in xrange(int(math.ceil(salt_len * 0.75))): + for i in range(int(math.ceil(salt_len * 0.75))): salt.append(random.randint(0, 255)) return _bytes_to_text(_pack_bytes(salt))[:salt_len] @@ -73,7 +73,7 @@ def upgrade_legacy_hash(legacy_hash, salt, sep="$"): legacy_hash), "Not a valid MD5 hexdigest" # this needs to be declared as b"" in 2to3 collapsed = "" - for i in xrange(16): + for i in range(16): # this needs to become a byte() call in 2to3 collapsed += chr(int(legacy_hash[2 * i:2 * i + 2], 16)) return "%s%s%s%s%s%s%s%s" % ( @@ -163,7 +163,7 @@ def create( # iterate the hashing algorithm over its own digest the specified # number of times - for i in xrange(2 ** rounds): + for i in range(2 ** rounds): hashed = algorithms[algorithm](hashed).digest() # concatenate the output fields, coercing into text form as needed -- 2.11.0