summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Collins <elic@assurancetechnologies.com>2020-10-06 14:25:15 -0400
committerEli Collins <elic@assurancetechnologies.com>2020-10-06 14:25:15 -0400
commitff4b4bbccd4756fb2f93d0b622c42bee3a4f93dd (patch)
tree708a1322ed0239f9fc56c2fb2dfeff16f8839d48
parent582508faa9eb193bd6941c3d484cc75eff8f2cc0 (diff)
downloadpasslib-ff4b4bbccd4756fb2f93d0b622c42bee3a4f93dd.tar.gz
cleanup old python compat -- removed irange() alias
-rw-r--r--passlib/context.py2
-rw-r--r--passlib/crypto/_blowfish/_gen_files.py9
-rw-r--r--passlib/crypto/_md4.py4
-rw-r--r--passlib/crypto/des.py5
-rw-r--r--passlib/crypto/digest.py26
-rw-r--r--passlib/handlers/oracle.py5
-rw-r--r--passlib/handlers/sha1_crypt.py4
-rw-r--r--passlib/handlers/sun_md5_crypt.py5
-rw-r--r--passlib/pwd.py6
-rw-r--r--passlib/tests/test_apache.py5
-rw-r--r--passlib/tests/test_context.py4
-rw-r--r--passlib/tests/test_handlers.py2
-rw-r--r--passlib/tests/test_handlers_bcrypt.py5
-rw-r--r--passlib/tests/test_utils.py11
-rw-r--r--passlib/tests/utils.py10
-rw-r--r--passlib/totp.py8
-rw-r--r--passlib/utils/__init__.py2
-rw-r--r--passlib/utils/binary.py8
-rw-r--r--passlib/utils/compat/__init__.py5
-rw-r--r--passlib/utils/handlers.py2
20 files changed, 58 insertions, 70 deletions
diff --git a/passlib/context.py b/passlib/context.py
index 330a306..9fcf130 100644
--- a/passlib/context.py
+++ b/passlib/context.py
@@ -17,7 +17,7 @@ from passlib.utils import (handlers as uh, to_bytes,
as_bool, timer, rng, getrandstr,
)
from passlib.utils.binary import BASE64_CHARS
-from passlib.utils.compat import (iteritems, num_types, irange,
+from passlib.utils.compat import (iteritems, num_types,
unicode, SafeConfigParser,
NativeStringIO, BytesIO,
unicode_or_bytes_types, native_string_types,
diff --git a/passlib/crypto/_blowfish/_gen_files.py b/passlib/crypto/_blowfish/_gen_files.py
index 2f92cf8..b1486e2 100644
--- a/passlib/crypto/_blowfish/_gen_files.py
+++ b/passlib/crypto/_blowfish/_gen_files.py
@@ -6,14 +6,13 @@
import os
import textwrap
# pkg
-from passlib.utils.compat import irange
# local
#=============================================================================
# helpers
#=============================================================================
def varlist(name, count):
- return ", ".join(name + str(x) for x in irange(count))
+ return ", ".join(name + str(x) for x in range(count))
def indent_block(block, padding):
@@ -30,7 +29,7 @@ BFSTR = """\
""".strip()
def render_encipher(write, indent=0):
- for i in irange(0, 15, 2):
+ for i in range(0, 15, 2):
write(indent, """\
# Feistel substitution on left word (round %(i)d)
r ^= %(left)s ^ p%(i1)d
@@ -74,7 +73,7 @@ def write_expand_function(write, indent=0):
# integrate key
#=============================================================
""")
- for i in irange(18):
+ for i in range(18):
write(indent+1, """\
p%(i)d = P[%(i)d] ^ key_words[%(i)d]
""", i=i)
@@ -99,7 +98,7 @@ def write_expand_function(write, indent=0):
""")
- for i in irange(2, 18, 2):
+ for i in range(2, 18, 2):
write(indent+1, """\
#------------------------------------------------
# update P[%(i)d] and P[%(i1)d]
diff --git a/passlib/crypto/_md4.py b/passlib/crypto/_md4.py
index 7d1a79c..e6ab63e 100644
--- a/passlib/crypto/_md4.py
+++ b/passlib/crypto/_md4.py
@@ -20,7 +20,7 @@ Implementated based on rfc at http://www.faqs.org/rfcs/rfc1320.html
from binascii import hexlify
import struct
# site
-from passlib.utils.compat import bascii_to_str, irange
+from passlib.utils.compat import bascii_to_str
# local
__all__ = ["md4"]
@@ -176,7 +176,7 @@ class md4(object):
state[a] = ((t<<s) & MASK_32) + (t>>(32-s))
# add back into original state
- for i in irange(4):
+ for i in range(4):
orig[i] = (orig[i]+state[i]) & MASK_32
def update(self, content):
diff --git a/passlib/crypto/des.py b/passlib/crypto/des.py
index 3f87aef..32fbf91 100644
--- a/passlib/crypto/des.py
+++ b/passlib/crypto/des.py
@@ -47,8 +47,7 @@ The netbsd des-crypt implementation has some nice notes on how this all works -
import struct
# pkg
from passlib import exc
-from passlib.utils.compat import join_byte_values, byte_elem_value, \
- irange, irange, int_types
+from passlib.utils.compat import join_byte_values, byte_elem_value, int_types
# local
__all__ = [
"expand_des_key",
@@ -606,7 +605,7 @@ def _unpack56(value):
## assert 0 <= value < 0x80, "value out of range"
## return (value<<1) | (0x9669 >> ((value ^ (value >> 4)) & 0xf)) & 1
-_EXPAND_ITER = irange(49,-7,-7)
+_EXPAND_ITER = range(49, -7, -7)
def expand_des_key(key):
"""convert DES from 7 bytes to 8 bytes (by inserting empty parity bits)"""
diff --git a/passlib/crypto/digest.py b/passlib/crypto/digest.py
index d70f8d1..eb37e6f 100644
--- a/passlib/crypto/digest.py
+++ b/passlib/crypto/digest.py
@@ -32,7 +32,7 @@ except ImportError:
from passlib import exc
from passlib.utils import join_bytes, to_native_str, join_byte_values, to_bytes, \
SequenceMixin, as_bool
-from passlib.utils.compat import irange, int_types, unicode_or_bytes_types, error_from
+from passlib.utils.compat import int_types, unicode_or_bytes_types, error_from
from passlib.utils.decor import memoized_property
# local
__all__ = [
@@ -616,8 +616,8 @@ if as_bool(os.environ.get("PASSLIB_MOCK_FIPS_MODE")):
#=============================================================================
#: translation tables used by compile_hmac()
-_TRANS_5C = join_byte_values((x ^ 0x5C) for x in irange(256))
-_TRANS_36 = join_byte_values((x ^ 0x36) for x in irange(256))
+_TRANS_5C = join_byte_values((x ^ 0x5C) for x in range(256))
+_TRANS_36 = join_byte_values((x ^ 0x36) for x in range(256))
def compile_hmac(digest, key, multipart=False):
"""
@@ -754,7 +754,7 @@ def pbkdf1(digest, secret, salt, rounds, keylen=None):
# main pbkdf1 loop
block = secret + salt
- for _ in irange(rounds):
+ for _ in range(rounds):
block = const(block).digest()
return block[:keylen]
@@ -860,7 +860,7 @@ def pbkdf2_hmac(digest, secret, salt, rounds, keylen=None):
# assemble & return result
return join_bytes(
calc_block(keyed_hmac, keyed_hmac(salt + _pack_uint32(i)), rounds)
- for i in irange(1, block_count + 1)
+ for i in range(1, block_count + 1)
)[:keylen]
#-------------------------------------------------------------------------------------
@@ -884,7 +884,7 @@ if _force_backend in ["any", "from-bytes"]:
from_bytes = int.from_bytes
BIG = "big" # endianess doesn't matter, just has to be consistent
accum = from_bytes(digest, BIG)
- for _ in irange(rounds - 1):
+ for _ in range(rounds - 1):
digest = keyed_hmac(digest)
accum ^= from_bytes(digest, BIG)
return accum.to_bytes(digest_size, BIG)
@@ -906,7 +906,7 @@ elif _force_backend in ["any", "unpack", "from-bytes"]:
def helper(keyed_hmac, digest, rounds):
accum = digest
- for _ in irange(rounds - 1):
+ for _ in range(rounds - 1):
digest = keyed_hmac(digest)
accum ^= digest
return accum
@@ -963,8 +963,8 @@ elif _force_backend in ["any", "unpack", "from-bytes"]:
#
tdict = dict(
digest_size=digest_size,
- accum_vars=", ".join("acc_%d" % i for i in irange(count)),
- digest_vars=", ".join("dig_%d" % i for i in irange(count)),
+ accum_vars=", ".join("acc_%d" % i for i in range(count)),
+ digest_vars=", ".join("dig_%d" % i for i in range(count)),
)
# head of function
@@ -973,13 +973,13 @@ elif _force_backend in ["any", "unpack", "from-bytes"]:
" '''pbkdf2 loop helper for digest_size={digest_size}'''\n"
" unpack_digest = struct.unpack\n"
" {accum_vars} = unpack_digest(digest)\n"
- " for _ in irange(1, rounds):\n"
+ " for _ in range(1, rounds):\n"
" digest = keyed_hmac(digest)\n"
" {digest_vars} = unpack_digest(digest)\n"
).format(**tdict)
# xor digest
- for i in irange(count):
+ for i in range(count):
source += " acc_%d ^= dig_%d\n" % (i, i)
# return result
@@ -989,7 +989,7 @@ elif _force_backend in ["any", "unpack", "from-bytes"]:
# compile helper
#
code = compile(source, "<generated by passlib.crypto.digest._get_pbkdf2_looper()>", "exec")
- gdict = dict(irange=irange, struct=struct)
+ gdict = dict(struct=struct)
ldict = dict()
eval(code, gdict, ldict)
helper = ldict['helper']
@@ -1019,7 +1019,7 @@ else:
def _pbkdf2_looper(keyed_hmac, digest, rounds):
hexlify = _hexlify
accum = int(hexlify(digest), 16)
- for _ in irange(rounds - 1):
+ for _ in range(rounds - 1):
digest = keyed_hmac(digest)
accum ^= int(hexlify(digest), 16)
return int_to_bytes(accum, len(digest))
diff --git a/passlib/handlers/oracle.py b/passlib/handlers/oracle.py
index 46b2260..34c4202 100644
--- a/passlib/handlers/oracle.py
+++ b/passlib/handlers/oracle.py
@@ -10,8 +10,7 @@ import logging; log = logging.getLogger(__name__)
# site
# pkg
from passlib.utils import to_unicode, xor_bytes
-from passlib.utils.compat import irange, \
- uascii_to_str, unicode, str_to_uascii
+from passlib.utils.compat import uascii_to_str, unicode, str_to_uascii
from passlib.crypto.des import des_encrypt_block
import passlib.utils.handlers as uh
# local
@@ -41,7 +40,7 @@ def des_cbc_encrypt(key, value, iv=b'\x00' * 8, pad=b'\x00'):
"""
value += pad * (-len(value) % 8) # null pad to multiple of 8
hash = iv # start things off
- for offset in irange(0,len(value),8):
+ for offset in range(0, len(value), 8):
chunk = xor_bytes(hash, value[offset:offset+8])
hash = des_encrypt_block(key, chunk)
return hash
diff --git a/passlib/handlers/sha1_crypt.py b/passlib/handlers/sha1_crypt.py
index ed1f1c0..393a59e 100644
--- a/passlib/handlers/sha1_crypt.py
+++ b/passlib/handlers/sha1_crypt.py
@@ -11,7 +11,7 @@ import logging; log = logging.getLogger(__name__)
# pkg
from passlib.utils import safe_crypt, test_crypt
from passlib.utils.binary import h64
-from passlib.utils.compat import unicode, irange
+from passlib.utils.compat import unicode
from passlib.crypto.digest import compile_hmac
import passlib.utils.handlers as uh
# local
@@ -135,7 +135,7 @@ class sha1_crypt(uh.HasManyBackends, uh.HasRounds, uh.HasSalt, uh.GenericHandler
result = (u"%s$sha1$%s" % (self.salt, rounds)).encode("ascii")
# NOTE: this algorithm is essentially PBKDF1, modified to use HMAC.
keyed_hmac = compile_hmac("sha1", secret)
- for _ in irange(rounds):
+ for _ in range(rounds):
result = keyed_hmac(result)
return h64.encode_transposed_bytes(result, self._chk_offsets).decode("ascii")
diff --git a/passlib/handlers/sun_md5_crypt.py b/passlib/handlers/sun_md5_crypt.py
index 40875fe..885613c 100644
--- a/passlib/handlers/sun_md5_crypt.py
+++ b/passlib/handlers/sun_md5_crypt.py
@@ -19,8 +19,7 @@ from warnings import warn
# pkg
from passlib.utils import to_unicode
from passlib.utils.binary import h64
-from passlib.utils.compat import byte_elem_value, irange, \
- uascii_to_str, unicode, str_to_bascii
+from passlib.utils.compat import byte_elem_value, uascii_to_str, unicode, str_to_bascii
import passlib.utils.handlers as uh
# local
__all__ = [
@@ -73,7 +72,7 @@ MAGIC_HAMLET = (
)
# NOTE: these sequences are pre-calculated iteration ranges used by X & Y loops w/in rounds function below
-xr = irange(7)
+xr = range(7)
_XY_ROUNDS = [
tuple((i,i,i+3) for i in xr), # xrounds 0
tuple((i,i+1,i+4) for i in xr), # xrounds 1
diff --git a/passlib/pwd.py b/passlib/pwd.py
index 599773d..7fecdd6 100644
--- a/passlib/pwd.py
+++ b/passlib/pwd.py
@@ -17,7 +17,7 @@ import os
# site
# pkg
from passlib import exc
-from passlib.utils.compat import irange, itervalues, int_types
+from passlib.utils.compat import itervalues, int_types
from passlib.utils import rng, getrandstr, to_unicode
from passlib.utils.decor import memoized_property
# local
@@ -304,7 +304,7 @@ class SequenceGenerator(object):
if returns is None:
return next(self)
elif isinstance(returns, int_types):
- return [next(self) for _ in irange(returns)]
+ return [next(self) for _ in range(returns)]
elif returns is iter:
return self
else:
@@ -673,7 +673,7 @@ class PhraseGenerator(SequenceGenerator):
#=============================================================================
def __next__(self):
- words = (self.rng.choice(self.words) for _ in irange(self.length))
+ words = (self.rng.choice(self.words) for _ in range(self.length))
return self.sep.join(words)
#=============================================================================
diff --git a/passlib/tests/test_apache.py b/passlib/tests/test_apache.py
index b380232..fcdbbc6 100644
--- a/passlib/tests/test_apache.py
+++ b/passlib/tests/test_apache.py
@@ -11,7 +11,6 @@ import subprocess
# pkg
from passlib import apache, registry
from passlib.exc import MissingBackendError
-from passlib.utils.compat import irange
from passlib.tests.utils import TestCase, get_file, set_file, ensure_mtime_changed
from passlib.utils import to_bytes
from passlib.utils.handlers import to_unicode_for_identify
@@ -242,7 +241,7 @@ class HtpasswdFileTest(TestCase):
# users 1..6 of sample_01 run through all the main hash formats,
# to make sure they're recognized.
- for i in irange(1, 7):
+ for i in range(1, 7):
i = str(i)
try:
self.assertTrue(ht.check_password("user"+i, "pass"+i))
@@ -590,7 +589,7 @@ class HtdigestFileTest(TestCase):
self.assertRaises(TypeError, ht.check_password, 1, 'realm', 'pass5')
self.assertRaises(TypeError, ht.check_password, 'user', 1, 'pass5')
self.assertIs(ht.check_password("user5", "realm","pass5"), None)
- for i in irange(1,5):
+ for i in range(1, 5):
i = str(i)
self.assertTrue(ht.check_password("user"+i, "realm", "pass"+i))
self.assertIs(ht.check_password("user"+i, "realm", "pass5"), False)
diff --git a/passlib/tests/test_context.py b/passlib/tests/test_context.py
index 3459adc..5a82d90 100644
--- a/passlib/tests/test_context.py
+++ b/passlib/tests/test_context.py
@@ -15,7 +15,7 @@ from passlib import hash
from passlib.context import CryptContext, LazyCryptContext
from passlib.exc import PasslibConfigWarning, PasslibHashWarning
from passlib.utils import tick, to_unicode
-from passlib.utils.compat import irange, unicode, str_to_uascii
+from passlib.utils.compat import unicode, str_to_uascii
import passlib.utils.handlers as uh
from passlib.tests.utils import (TestCase, set_file, TICK_RESOLUTION,
quicksleep, time_call, handler_derived_from)
@@ -1546,7 +1546,7 @@ sha512_crypt__min_rounds = 45000
handler = context.handler(scheme)
salt = handler.default_salt_chars[0:1] * handler.max_salt_size
seen = set()
- for i in irange(300):
+ for i in range(300):
h = context.genconfig(scheme, salt=salt)
r = handler.from_string(h).rounds
seen.add(r)
diff --git a/passlib/tests/test_handlers.py b/passlib/tests/test_handlers.py
index 38836fa..757c089 100644
--- a/passlib/tests/test_handlers.py
+++ b/passlib/tests/test_handlers.py
@@ -11,7 +11,7 @@ import warnings
# pkg
from passlib import exc, hash
from passlib.utils import repeat_string
-from passlib.utils.compat import irange, get_method_function
+from passlib.utils.compat import range, get_method_function
from passlib.tests.utils import TestCase, HandlerCase, skipUnless, \
TEST_MODE, UserHandlerMixin, EncodingHandlerMixin
# module
diff --git a/passlib/tests/test_handlers_bcrypt.py b/passlib/tests/test_handlers_bcrypt.py
index 55d5203..5b70a99 100644
--- a/passlib/tests/test_handlers_bcrypt.py
+++ b/passlib/tests/test_handlers_bcrypt.py
@@ -11,7 +11,6 @@ import warnings
from passlib import hash
from passlib.handlers.bcrypt import IDENT_2, IDENT_2X
from passlib.utils import repeat_string, to_bytes, is_safe_crypt_input
-from passlib.utils.compat import irange
from passlib.tests.utils import HandlerCase, TEST_MODE
from passlib.tests.test_handlers import UPASS_TABLE
# module
@@ -365,9 +364,9 @@ class _bcrypt_test(HandlerCase):
"unexpectedly malformed hash: %r" % (hash,)
self.assertTrue(hash[28] in '.Oeu',
"unused bits incorrectly set in hash: %r" % (hash,))
- for i in irange(6):
+ for i in range(6):
check_padding(bcrypt.genconfig())
- for i in irange(3):
+ for i in range(3):
check_padding(bcrypt.using(rounds=bcrypt.min_rounds).hash("bob"))
#
diff --git a/passlib/tests/test_utils.py b/passlib/tests/test_utils.py
index 6790794..39f69bd 100644
--- a/passlib/tests/test_utils.py
+++ b/passlib/tests/test_utils.py
@@ -9,7 +9,7 @@ import warnings
# pkg
# module
from passlib.utils import is_ascii_safe, to_bytes
-from passlib.utils.compat import irange, unicode, join_bytes, PYPY
+from passlib.utils.compat import unicode, join_bytes, PYPY
from passlib.tests.utils import TestCase, hb, run_with_fixed_seeds
#=============================================================================
@@ -30,7 +30,6 @@ class MiscTest(TestCase):
# test synthentic dir()
dir(compat)
self.assertTrue('UnicodeIO' in dir(compat))
- self.assertTrue('irange' in dir(compat))
def test_classproperty(self):
from passlib.utils.decor import classproperty
@@ -322,12 +321,12 @@ class MiscTest(TestCase):
# NOTE: below code was used to generate stats for analysis
##from math import log as logb
##import timeit
- ##multipliers = [ 1<<s for s in irange(9)]
+ ##multipliers = [ 1<<s for s in range(9)]
##correct = u"abcdefgh"*(1<<4)
##incorrect = u"abcdxfgh"
##print
##first = True
- ##for run in irange(1):
+ ##for run in range(1):
## times = []
## chars = []
## for m in multipliers:
@@ -879,7 +878,7 @@ class _Base64Test(TestCase):
from passlib.utils import getrandbytes, getrandstr
rng = self.getRandom()
saw_zero = False
- for i in irange(500):
+ for i in range(500):
#
# test raw -> encode() -> decode() -> raw
#
@@ -1028,7 +1027,7 @@ class _Base64Test(TestCase):
# do random testing.
from passlib.utils import getrandstr
- for i in irange(100):
+ for i in range(100):
# generate random value, encode, and then decode
value = rng.randint(0, upper-1)
encoded = encode(value)
diff --git a/passlib/tests/utils.py b/passlib/tests/utils.py
index e55ce3e..6fad419 100644
--- a/passlib/tests/utils.py
+++ b/passlib/tests/utils.py
@@ -28,7 +28,7 @@ import passlib.registry as registry
from passlib.utils import has_rounds_info, has_salt_info, rounds_cost_values, \
rng as sys_rng, getrandstr, is_ascii_safe, to_native_str, \
repeat_string, tick, batch
-from passlib.utils.compat import iteritems, irange, unicode
+from passlib.utils.compat import iteritems, unicode
from passlib.utils.decor import classproperty
import passlib.utils.handlers as uh
# local
@@ -282,7 +282,7 @@ def run_with_fixed_seeds(count=128, master_seed=0x243F6A8885A308D3):
@wraps(func)
def wrapper(*args, **kwds):
rng = random.Random(master_seed)
- for _ in irange(count):
+ for _ in range(count):
kwds['seed'] = rng.getrandbits(32)
func(*args, **kwds)
return wrapper
@@ -1315,7 +1315,7 @@ class HandlerCase(TestCase):
def sampler(func):
value1 = func()
- for _ in irange(samples):
+ for _ in range(samples):
value2 = func()
if value1 != value2:
return
@@ -1866,7 +1866,7 @@ class HandlerCase(TestCase):
handler, subcls, small, medium, large, adj = self._create_using_rounds_helper()
def get_effective_range(cls):
- seen = set(get_effective_rounds(cls) for _ in irange(1000))
+ seen = set(get_effective_rounds(cls) for _ in range(1000))
return min(seen), max(seen)
def assert_rounds_range(vary_rounds, lower, upper):
@@ -2736,7 +2736,7 @@ class HandlerCase(TestCase):
thread.setDaemon(True)
thread.start()
return thread
- threads = [launch(n) for n in irange(thread_count)]
+ threads = [launch(n) for n in range(thread_count)]
# wait until all threads exit
timeout = self.max_fuzz_time * thread_count * 4
diff --git a/passlib/totp.py b/passlib/totp.py
index 1835632..73605f2 100644
--- a/passlib/totp.py
+++ b/passlib/totp.py
@@ -32,7 +32,7 @@ from passlib.utils import (to_unicode, to_bytes, consteq,
getrandbytes, rng, SequenceMixin, xor_bytes, getrandstr)
from passlib.utils.binary import BASE64_CHARS, b32encode, b32decode
from passlib.utils.compat import (u, unicode, native_string_types, bascii_to_str, int_types, num_types,
- irange, byte_elem_value, UnicodeIO, suppress_cause)
+ byte_elem_value, UnicodeIO, suppress_cause)
from passlib.utils.decor import hybrid_method, memoized_property
from passlib.crypto.digest import lookup_hash, compile_hmac, pbkdf2_hmac
from passlib.hash import pbkdf2_sha256
@@ -92,7 +92,7 @@ def group_string(value, sep="-"):
"""
klen = len(value)
size = _get_group_size(klen)
- return sep.join(value[o:o+size] for o in irange(0, klen, size))
+ return sep.join(value[o:o+size] for o in range(0, klen, size))
#-----------------------------------------------------------------------------
# encoding helpers
@@ -1273,8 +1273,8 @@ class TOTP(object):
# XXX: if (end - start) is very large (e.g. for resync purposes),
# could start with expected value, and work outward from there,
# alternately checking before & after it until match is found.
- # XXX: can't use irange(start, end) here since py2x/win32
- # throws error on values >= (1<<31), which 'end' can be.
+ # TODO: replace counter loop with "for counter in range(start, end)";
+ # think this was holding from PY2+win32 issue with values > 32 bit (e.g. 'end').
counter = start
while counter < end:
if consteq(token, generate(counter)):
diff --git a/passlib/utils/__init__.py b/passlib/utils/__init__.py
index e25d861..b9041ce 100644
--- a/passlib/utils/__init__.py
+++ b/passlib/utils/__init__.py
@@ -62,7 +62,7 @@ from passlib.utils.decor import (
)
from passlib.exc import ExpectedStringError, ExpectedTypeError
from passlib.utils.compat import (add_doc, join_bytes, join_byte_values,
- join_byte_elems, irange, imap,
+ join_byte_elems, imap,
join_unicode, unicode, byte_elem_value, nextgetter,
unicode_or_str, unicode_or_bytes_types,
get_method_function, suppress_cause, PYPY)
diff --git a/passlib/utils/binary.py b/passlib/utils/binary.py
index bdef73b..d64642e 100644
--- a/passlib/utils/binary.py
+++ b/passlib/utils/binary.py
@@ -19,7 +19,7 @@ log = logging.getLogger(__name__)
from passlib import exc
from passlib.utils.compat import (
bascii_to_str,
- irange, imap, iter_byte_chars, join_byte_values, join_byte_elems,
+ imap, iter_byte_chars, join_byte_values, join_byte_elems,
nextgetter, suppress_cause,
unicode, unicode_or_bytes_types,
)
@@ -92,7 +92,7 @@ LOWER_HEX_CHARS = u"0123456789abcdef"
#: special byte string containing all possible byte values
#: NOTE: for efficiency, this is treated as singleton by some of the code
-ALL_BYTE_VALUES = join_byte_values(irange(256))
+ALL_BYTE_VALUES = join_byte_values(range(256))
#: some string constants we reuse
B_EMPTY = b''
@@ -786,11 +786,11 @@ class Base64Engine(object):
pad = -bits % 6
bits += pad
if self.big:
- itr = irange(bits-6, -6, -6)
+ itr = range(bits-6, -6, -6)
# shift to add lsb padding.
value <<= pad
else:
- itr = irange(0, bits, 6)
+ itr = range(0, bits, 6)
# padding is msb, so no change needed.
return join_byte_elems(imap(self._encode64,
((value>>off) & 0x3f for off in itr)))
diff --git a/passlib/utils/compat/__init__.py b/passlib/utils/compat/__init__.py
index 2ad834e..457a90f 100644
--- a/passlib/utils/compat/__init__.py
+++ b/passlib/utils/compat/__init__.py
@@ -61,7 +61,6 @@ __all__ = [
'iter_byte_values',
# iteration helpers
- 'irange', #'lrange',
'imap', 'lmap',
'iteritems', 'itervalues',
'next',
@@ -175,16 +174,12 @@ num_types = (int, float)
#=============================================================================
# iteration helpers
#
-# irange - range iterable / view (xrange under py2, range under py3)
# lrange - range list (range under py2, list(range()) under py3)
#
# imap - map to iterator
# lmap - map to list
#=============================================================================
if True: # legacy PY3 indent
- irange = range
- ##def lrange(*a,**k):
- ## return list(range(*a,**k))
def lmap(*a, **k):
return list(map(*a,**k))
diff --git a/passlib/utils/handlers.py b/passlib/utils/handlers.py
index 8034cc3..8fa797d 100644
--- a/passlib/utils/handlers.py
+++ b/passlib/utils/handlers.py
@@ -26,7 +26,7 @@ from passlib.utils.binary import (
HEX_CHARS, UPPER_HEX_CHARS, LOWER_HEX_CHARS,
ALL_BYTE_VALUES,
)
-from passlib.utils.compat import join_byte_values, irange, native_string_types, \
+from passlib.utils.compat import join_byte_values, native_string_types, \
uascii_to_str, join_unicode, unicode, str_to_uascii, \
join_unicode, unicode_or_bytes_types, int_types
from passlib.utils.decor import classproperty, deprecated_method