Commit 23042cda authored by Raymond Hettinger's avatar Raymond Hettinger

Issue #21470: Do a better job seeding the random number generator

to fully cover its state space.
parent 2f46a0e8
...@@ -105,7 +105,9 @@ class Random(_random.Random): ...@@ -105,7 +105,9 @@ class Random(_random.Random):
if a is None: if a is None:
try: 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: except NotImplementedError:
import time import time
a = int(time.time() * 256) # use fractional seconds a = int(time.time() * 256) # use fractional seconds
......
...@@ -26,6 +26,9 @@ Library ...@@ -26,6 +26,9 @@ Library
- Issue #21396: Fix TextIOWrapper(..., write_through=True) to not force a - Issue #21396: Fix TextIOWrapper(..., write_through=True) to not force a
flush() on the underlying binary stream. Patch by akira. flush() on the underlying binary stream. Patch by akira.
- Issue #21470: Do a better job seeding the random number generator by
using enough bytes to span the full state space of the Mersenne Twister.
- Issue #21398: Fix an unicode error in the pydoc pager when the documentation - Issue #21398: Fix an unicode error in the pydoc pager when the documentation
contains characters not encodable to the stdout encoding. contains characters not encodable to the stdout encoding.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment