Issue #27706: Fix regression in random.seed(somestr, version=1)
diff --git a/Lib/random.py b/Lib/random.py
index 5950735..06513c8 100644
--- a/Lib/random.py
+++ b/Lib/random.py
@@ -112,6 +112,13 @@
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):