Update rndstr to use string.ascii_letters for py3k

Python3 has eliminated string.letters, and also makes dealing with
arrays of bytes somewhat tricky. Luckily string.ascii_letters returns
str.
This commit is contained in:
Clint Byrum
2015-05-17 01:05:45 -07:00
parent dc65c85f8f
commit 317a975c56

View File

@@ -164,8 +164,8 @@ def rndstr(size=16, alphabet=""):
"""
rng = random.SystemRandom()
if not alphabet:
alphabet = string.letters[0:52] + string.digits
return str().join(rng.choice(alphabet) for _ in range(size))
alphabet = string.ascii_letters[0:52] + string.digits
return type(alphabet)().join(rng.choice(alphabet) for _ in range(size))
def sid():