]> granicus.if.org Git - python/commitdiff
Keep asyncio working with Python 3.3 too.
authorGuido van Rossum <guido@python.org>
Sat, 23 Nov 2013 23:36:43 +0000 (15:36 -0800)
committerGuido van Rossum <guido@python.org>
Sat, 23 Nov 2013 23:36:43 +0000 (15:36 -0800)
Lib/asyncio/selector_events.py

index 14c97000e66f0fe8131034d98b74465a081bbb33..0641459f96e6e9f21bd4bf288b289dece660ad06 100644 (file)
@@ -571,8 +571,15 @@ class _SelectorSslTransport(_SelectorTransport):
                 # context; in that case the sslcontext passed is None.
                 # The default is the same as used by urllib with
                 # cadefault=True.
-                sslcontext = ssl._create_stdlib_context(
-                    cert_reqs=ssl.CERT_REQUIRED)
+                if hasattr(ssl, '_create_stdlib_context'):
+                    sslcontext = ssl._create_stdlib_context(
+                        cert_reqs=ssl.CERT_REQUIRED)
+                else:
+                    # Fallback for Python 3.3.
+                    sslcontext = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+                    sslcontext.options |= ssl.OP_NO_SSLv2
+                    sslcontext.set_default_verify_paths()
+                    sslcontext.verify_mode = ssl.CERT_REQUIRED
 
         wrap_kwargs = {
             'server_side': server_side,