From 23042cda40bdab21db36a92d5d2655046207f947 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Tue, 13 May 2014 22:13:40 -0700 Subject: Issue #21470: Do a better job seeding the random number generator to fully cover its state space. --- Lib/random.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Lib/random.py') diff --git a/Lib/random.py b/Lib/random.py index 808175ab4a..174e755a02 100644 --- a/Lib/random.py +++ b/Lib/random.py @@ -105,7 +105,9 @@ class Random(_random.Random): if a is None: try: - a = int.from_bytes(_urandom(32), 'big') + # Seed with enough bytes to span the 19937 bit + # state space for the Mersenne Twister + a = int.from_bytes(_urandom(2500), 'big') except NotImplementedError: import time a = int(time.time() * 256) # use fractional seconds -- cgit v1.2.1