mirror of
https://github.com/python/cpython.git
synced 2025-08-24 18:55:00 +00:00
os.urandom() now blocks on Linux
Issue #27776: The os.urandom() function does now block on Linux 3.17 and newer until the system urandom entropy pool is initialized to increase the security. This change is part of the PEP 524.
This commit is contained in:
parent
e256accd46
commit
e66987e626
8 changed files with 130 additions and 59 deletions
|
@ -105,15 +105,6 @@ class Random(_random.Random):
|
|||
|
||||
"""
|
||||
|
||||
if a is None:
|
||||
try:
|
||||
# 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
|
||||
|
||||
if version == 1 and isinstance(a, (str, bytes)):
|
||||
x = ord(a[0]) << 7 if a else 0
|
||||
for c in a:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue