summaryrefslogtreecommitdiff
path: root/Lib/random.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/random.py')
-rw-r--r--Lib/random.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/random.py b/Lib/random.py
index 01c0c3d25f..91065b7e30 100644
--- a/Lib/random.py
+++ b/Lib/random.py
@@ -110,9 +110,10 @@ class Random(_random.Random):
"""
if version == 1 and isinstance(a, (str, bytes)):
+ a = a.decode('latin-1') if isinstance(a, bytes) else a
x = ord(a[0]) << 7 if a else 0
- for c in a:
- x = ((1000003 * x) ^ ord(c)) & 0xFFFFFFFFFFFFFFFF
+ for c in map(ord, a):
+ x = ((1000003 * x) ^ c) & 0xFFFFFFFFFFFFFFFF
x ^= len(a)
a = -2 if x == -1 else x