Skip to content

Commit 9a45889

Browse files
committed
Keep asyncio working with Python 3.3 too.
1 parent 440f941 commit 9a45889

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

asyncio/selector_events.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -571,10 +571,15 @@ def __init__(self, loop, rawsock, protocol, sslcontext, waiter=None,
571571
# context; in that case the sslcontext passed is None.
572572
# The default is the same as used by urllib with
573573
# cadefault=True.
574-
sslcontext = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
575-
sslcontext.options |= ssl.OP_NO_SSLv2
576-
sslcontext.set_default_verify_paths()
577-
sslcontext.verify_mode = ssl.CERT_REQUIRED
574+
if hasattr(ssl, '_create_stdlib_context'):
575+
sslcontext = ssl._create_stdlib_context(
576+
cert_reqs=ssl.CERT_REQUIRED)
577+
else:
578+
# Fallback for Python 3.3.
579+
sslcontext = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
580+
sslcontext.options |= ssl.OP_NO_SSLv2
581+
sslcontext.set_default_verify_paths()
582+
sslcontext.verify_mode = ssl.CERT_REQUIRED
578583

579584
wrap_kwargs = {
580585
'server_side': server_side,

0 commit comments

Comments
 (0)