This commit is contained in:
Raymond Hettinger 2016-08-31 15:01:28 -07:00
commit 112835cb3e
3 changed files with 30 additions and 0 deletions

View file

@ -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):