summaryrefslogtreecommitdiff
path: root/Lib/random.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2014-05-13 22:13:40 -0700
committerRaymond Hettinger <python@rcn.com>2014-05-13 22:13:40 -0700
commit23042cda40bdab21db36a92d5d2655046207f947 (patch)
treeef81353c09168980500d5d4d67590131280657e9 /Lib/random.py
parent2f46a0e8bef2e0a29e032ef805e9a95924af00a7 (diff)
downloadcpython-git-23042cda40bdab21db36a92d5d2655046207f947.tar.gz
Issue #21470: Do a better job seeding the random number generator
to fully cover its state space.
Diffstat (limited to 'Lib/random.py')
-rw-r--r--Lib/random.py4
1 files changed, 3 insertions, 1 deletions
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