From c7bab7cbf5d6a8b442f2ed3e23543cb4ee826c87 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Wed, 31 Aug 2016 15:01:08 -0700 Subject: Issue #27706: Fix regression in random.seed(somestr, version=1) --- Lib/random.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'Lib/random.py') diff --git a/Lib/random.py b/Lib/random.py index 5950735e3e..06513c824f 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): -- cgit v1.2.1