1. mirror
  2. cpython

Commits

Raymond Hettinger  committed c203df9

Issue #21470: Do a better job seeding the random number generator
to fully cover its state space.

  • Participants
  • Parent commits 16d2639
  • Branches 3.4

Comments (0)

Files changed (2)

File Lib/random.py

View file
 
         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

File Misc/NEWS

View file
 - Issue #21396: Fix TextIOWrapper(..., write_through=True) to not force a
   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
   contains characters not encodable to the stdout encoding.