summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-01-05 20:21:38 +0100
committerVictor Stinner <victor.stinner@gmail.com>2014-01-05 20:21:38 +0100
commitcfa5751774c4e921f71516d040890ff2040e0172 (patch)
tree46bb760a61d29d3a0f5f8a31b617a3a860b967cd
parent12e4cebce748073caeb383d0b4398b78e24ba891 (diff)
downloadtrollius-cfa5751774c4e921f71516d040890ff2040e0172.tar.gz
Don't export backported SSLContext in the ssl module anymore to not confuse
libraries testing hasattr(ssl, "SSLContext").
-rw-r--r--README2
-rw-r--r--asyncio/__init__.py2
-rw-r--r--asyncio/backport_ssl.py4
-rw-r--r--asyncio/selector_events.py3
-rw-r--r--asyncio/test_utils.py3
-rw-r--r--examples/cachesvr.py2
-rw-r--r--examples/sink.py2
-rw-r--r--tests/test_events.py9
8 files changed, 18 insertions, 9 deletions
diff --git a/README b/README
index 9055439..859ae6c 100644
--- a/README
+++ b/README
@@ -79,6 +79,8 @@ Change log
Development version
+- Don't export backported SSLContext in the ssl module anymore to not confuse
+ libraries testing hasattr(ssl, "SSLContext")
- Fix asyncio.time_monotonic on Mac OS X
2014-01-04: version 0.1
diff --git a/asyncio/__init__.py b/asyncio/__init__.py
index 786b85b..9d24085 100644
--- a/asyncio/__init__.py
+++ b/asyncio/__init__.py
@@ -22,6 +22,7 @@ if sys.platform == 'win32':
# This relies on each of the submodules having an __all__ variable.
from .futures import *
+from .backport_ssl import *
from .events import *
from .locks import *
from .transports import *
@@ -36,6 +37,7 @@ else:
__all__ = (futures.__all__ +
+ backport_ssl.__all__ +
events.__all__ +
locks.__all__ +
transports.__all__ +
diff --git a/asyncio/backport_ssl.py b/asyncio/backport_ssl.py
index c6c38a4..b3bd4a0 100644
--- a/asyncio/backport_ssl.py
+++ b/asyncio/backport_ssl.py
@@ -1,6 +1,8 @@
import ssl
from asyncio.backport import _wrap_error
+__all__ = ["SSLContext"]
+
# SSL constants copied from /usr/include/openssl/ssl.h of Fedora 19
#define SSL_ERROR_ZERO_RETURN 6
#define SSL_ERROR_WANT_ACCEPT 8
@@ -39,7 +41,7 @@ class SSLContext(object):
# FIXME: Ugly hack to not have to patch various modules
ssl.SSLWantReadError = SSLWantReadError
ssl.SSLWantWriteError = SSLWantWriteError
-ssl.SSLContext = SSLContext
+#ssl.SSLContext = SSLContext
_MAP_ERRORS = {
ssl.SSL_ERROR_WANT_READ: SSLWantReadError,
diff --git a/asyncio/selector_events.py b/asyncio/selector_events.py
index 3708f6f..c41dcbc 100644
--- a/asyncio/selector_events.py
+++ b/asyncio/selector_events.py
@@ -14,6 +14,7 @@ except ImportError: # pragma: no cover
ssl = None
from . import base_events
+from . import backport_ssl
from . import constants
from . import events
from . import futures
@@ -594,7 +595,7 @@ class _SelectorSslTransport(_SelectorTransport):
check_hostname=bool(server_hostname))
else:
# Fallback for Python 3.3.
- sslcontext = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ sslcontext = backport_asyncio.SSLContext(ssl.PROTOCOL_SSLv23)
sslcontext.options |= ssl.OP_NO_SSLv2
sslcontext.set_default_verify_paths()
sslcontext.verify_mode = ssl.CERT_REQUIRED
diff --git a/asyncio/test_utils.py b/asyncio/test_utils.py
index c8f5805..1583c2f 100644
--- a/asyncio/test_utils.py
+++ b/asyncio/test_utils.py
@@ -16,6 +16,7 @@ except ImportError: # pragma: no cover
ssl = None
from . import tasks
+from . import backport_ssl
from . import base_events
from . import events
from . import selectors
@@ -31,7 +32,7 @@ def dummy_ssl_context():
if ssl is None:
return None
else:
- return ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ return backport_ssl.SSLContext(ssl.PROTOCOL_SSLv23)
def run_briefly(loop):
diff --git a/examples/cachesvr.py b/examples/cachesvr.py
index 9c7bda9..a265794 100644
--- a/examples/cachesvr.py
+++ b/examples/cachesvr.py
@@ -227,7 +227,7 @@ def main():
import ssl
# TODO: take cert/key from args as well.
here = os.path.join(os.path.dirname(__file__), '..', 'tests')
- sslctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ sslctx = asyncio.SSLContext(ssl.PROTOCOL_SSLv23)
sslctx.options |= ssl.OP_NO_SSLv2
sslctx.load_cert_chain(
certfile=os.path.join(here, 'ssl_cert.pem'),
diff --git a/examples/sink.py b/examples/sink.py
index b3ac3e8..f78c38c 100644
--- a/examples/sink.py
+++ b/examples/sink.py
@@ -64,7 +64,7 @@ def start(loop, host, port):
import ssl
# TODO: take cert/key from args as well.
here = os.path.join(os.path.dirname(__file__), '..', 'tests')
- sslctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ sslctx = SSLContext(ssl.PROTOCOL_SSLv23)
if hasattr(sslctx, 'options'):
sslctx.options |= ssl.OP_NO_SSLv2
sslctx.load_cert_chain(
diff --git a/tests/test_events.py b/tests/test_events.py
index fa4798b..74e7e57 100644
--- a/tests/test_events.py
+++ b/tests/test_events.py
@@ -39,6 +39,7 @@ from asyncio import locks
from asyncio.backport import wrap_error
from asyncio.time_monotonic import time_monotonic
from asyncio import test_support as support # find_unused_port, IPV6_ENABLED, TEST_HOME_DIR
+import asyncio
def data_file(filename):
@@ -614,7 +615,7 @@ class EventLoopTestsMixin(object):
server.close()
def _make_ssl_server(self, factory, certfile, keyfile=None):
- sslcontext = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ sslcontext = asyncio.SSLContext(ssl.PROTOCOL_SSLv23)
if hasattr(sslcontext, 'options'):
sslcontext.options |= ssl.OP_NO_SSLv2
sslcontext.load_cert_chain(certfile, keyfile)
@@ -685,7 +686,7 @@ class EventLoopTestsMixin(object):
server, host, port = self._make_ssl_server(factory, SIGNED_CERTFILE)
- sslcontext_client = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ sslcontext_client = asyncio.SSLContext(ssl.PROTOCOL_SSLv23)
if hasattr(sslcontext, 'options'):
sslcontext_client.options |= ssl.OP_NO_SSLv2
sslcontext_client.verify_mode = ssl.CERT_REQUIRED
@@ -714,7 +715,7 @@ class EventLoopTestsMixin(object):
server, host, port = self._make_ssl_server(factory, SIGNED_CERTFILE)
- sslcontext_client = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ sslcontext_client = asyncio.SSLContext(ssl.PROTOCOL_SSLv23)
if hasattr(sslcontext, 'options'):
sslcontext_client.options |= ssl.OP_NO_SSLv2
sslcontext_client.verify_mode = ssl.CERT_REQUIRED
@@ -746,7 +747,7 @@ class EventLoopTestsMixin(object):
server, host, port = self._make_ssl_server(factory, SIGNED_CERTFILE)
- sslcontext_client = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ sslcontext_client = asyncio.SSLContext(ssl.PROTOCOL_SSLv23)
if hasattr(sslcontext, 'options'):
sslcontext_client.options |= ssl.OP_NO_SSLv2
sslcontext_client.verify_mode = ssl.CERT_REQUIRED