mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
Issue #22585: On OpenBSD 5.6 and newer, os.urandom() now calls getentropy(),
instead of reading /dev/urandom, to get pseudo-random bytes.
This commit is contained in:
parent
3c6fe4da88
commit
4d6a3d6c01
6 changed files with 50 additions and 6 deletions
|
@ -27,6 +27,7 @@ import codecs
|
|||
import decimal
|
||||
import fractions
|
||||
import pickle
|
||||
import sysconfig
|
||||
try:
|
||||
import threading
|
||||
except ImportError:
|
||||
|
@ -1103,6 +1104,12 @@ class URandomTests(unittest.TestCase):
|
|||
data2 = self.get_urandom_subprocess(16)
|
||||
self.assertNotEqual(data1, data2)
|
||||
|
||||
|
||||
HAVE_GETENTROPY = (sysconfig.get_config_var('HAVE_GETENTROPY') == 1)
|
||||
|
||||
@unittest.skipIf(HAVE_GETENTROPY,
|
||||
"getentropy() does not use a file descriptor")
|
||||
class URandomFDTests(unittest.TestCase):
|
||||
@unittest.skipUnless(resource, "test requires the resource module")
|
||||
def test_urandom_failure(self):
|
||||
# Check urandom() failing when it is not able to open /dev/random.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue