summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-11-28 12:28:25 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-11-28 12:28:25 (GMT)
commitbeeb512fe1d8c502d854d7e27742a7481bccd5c4 (patch)
tree8e89fe1a29f57d4ea5f0e095110f257d77680a00 /Lib
parent07ff92a0d2c98f55bd863cdc5d6f62975f4994e5 (diff)
downloadcpython-beeb512fe1d8c502d854d7e27742a7481bccd5c4.zip
cpython-beeb512fe1d8c502d854d7e27742a7481bccd5c4.tar.gz
cpython-beeb512fe1d8c502d854d7e27742a7481bccd5c4.tar.bz2
Issue #21356: Make ssl.RAND_egd() optional to support LibreSSL. The
availability of the function is checked during the compilation. Patch written by Bernard Spil.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/ssl.py7
-rw-r--r--Lib/test/test_ssl.py5
2 files changed, 9 insertions, 3 deletions
diff --git a/Lib/ssl.py b/Lib/ssl.py
index 3d132b2..9264699 100644
--- a/Lib/ssl.py
+++ b/Lib/ssl.py
@@ -106,7 +106,12 @@ from _ssl import CERT_NONE, CERT_OPTIONAL, CERT_REQUIRED
from _ssl import (VERIFY_DEFAULT, VERIFY_CRL_CHECK_LEAF, VERIFY_CRL_CHECK_CHAIN,
VERIFY_X509_STRICT)
from _ssl import txt2obj as _txt2obj, nid2obj as _nid2obj
-from _ssl import RAND_status, RAND_egd, RAND_add, RAND_bytes, RAND_pseudo_bytes
+from _ssl import RAND_status, RAND_add, RAND_bytes, RAND_pseudo_bytes
+try:
+ from _ssl import RAND_egd
+except ImportError:
+ # LibreSSL does not provide RAND_egd
+ pass
def _import_symbols(prefix):
for n in dir(_ssl):
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
index 06705b2..2a18cc4 100644
--- a/Lib/test/test_ssl.py
+++ b/Lib/test/test_ssl.py
@@ -168,8 +168,9 @@ class BasicSocketTests(unittest.TestCase):
self.assertRaises(ValueError, ssl.RAND_bytes, -5)
self.assertRaises(ValueError, ssl.RAND_pseudo_bytes, -5)
- self.assertRaises(TypeError, ssl.RAND_egd, 1)
- self.assertRaises(TypeError, ssl.RAND_egd, 'foo', 1)
+ if hasattr(ssl, 'RAND_egd'):
+ self.assertRaises(TypeError, ssl.RAND_egd, 1)
+ self.assertRaises(TypeError, ssl.RAND_egd, 'foo', 1)
ssl.RAND_add("this is a random string", 75.0)
@unittest.skipUnless(os.name == 'posix', 'requires posix')