diff options
author | Raymond Hettinger <python@rcn.com> | 2016-08-31 15:01:28 -0700 |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2016-08-31 15:01:28 -0700 |
commit | 112835cb3e8423046a21e427d050f3e3fefe622b (patch) | |
tree | 5d4540b67d5b07a68fb0c6bfd8cd16658dc5d061 /Lib/random.py | |
parent | 898ac56fc2667af051b739cdbc2f8aba97ebf09c (diff) | |
parent | c7bab7cbf5d6a8b442f2ed3e23543cb4ee826c87 (diff) | |
download | cpython-git-112835cb3e8423046a21e427d050f3e3fefe622b.tar.gz |
Merge
Diffstat (limited to 'Lib/random.py')
-rw-r--r-- | Lib/random.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/random.py b/Lib/random.py index 1cffb0aaad..0178693ba9 100644 --- a/Lib/random.py +++ b/Lib/random.py @@ -112,6 +112,13 @@ class Random(_random.Random): import time a = int(time.time() * 256) # use fractional seconds + if version == 1 and isinstance(a, (str, bytes)): + x = ord(a[0]) << 7 if a else 0 + for c in a: + x = ((1000003 * x) ^ ord(c)) & 0xFFFFFFFFFFFFFFFF + x ^= len(a) + a = -2 if x == -1 else x + if version == 2: if isinstance(a, (str, bytes, bytearray)): if isinstance(a, str): |