diff options
author | Raymond Hettinger <rhettinger@users.noreply.github.com> | 2017-09-17 16:04:30 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-17 16:04:30 (GMT) |
commit | 132a7d7cdbc7cb89fa1c1f4e8192241c3d68f549 (patch) | |
tree | 0bea6a6e7b67c4420532f2857eda3efd8dd612a4 /Lib/random.py | |
parent | 63c591c0b0b57870a606e8edc59afe6264e7504d (diff) | |
download | cpython-132a7d7cdbc7cb89fa1c1f4e8192241c3d68f549.zip cpython-132a7d7cdbc7cb89fa1c1f4e8192241c3d68f549.tar.gz cpython-132a7d7cdbc7cb89fa1c1f4e8192241c3d68f549.tar.bz2 |
bpo-31482: Missing bytes support for random.seed() version 1 (#3614)
bpo-31482: Missing bytes support for random.seed() version 1 #3614
Diffstat (limited to 'Lib/random.py')
-rw-r--r-- | Lib/random.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/random.py b/Lib/random.py index 01c0c3d..91065b7 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 |