Skip to content

Commit

Permalink
Fix import ssl may fail under some Python installs
Browse files Browse the repository at this point in the history
It's only required for certain proxy configurations, so we
don't want it to raise ImportError while the user imports
our library.
  • Loading branch information
Lonami committed Oct 31, 2019
1 parent 6850903 commit 7e34618
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion telethon/network/connection/connection.py
Original file line number Diff line number Diff line change
@@ -1,9 1,13 @@
import abc
import asyncio
import socket
import ssl as ssl_mod
import sys

try:
import ssl as ssl_mod
except ImportError:
ssl_mod = None

from ...errors import InvalidChecksumError
from ... import helpers

Expand Down Expand Up @@ -68,6 72,12 @@ async def _connect(self, timeout=None, ssl=None):
loop=self._loop
)
if ssl:
if ssl_mod is None:
raise RuntimeError(
'Cannot use proxy that requires SSL'
'without the SSL module being available'
)

s.settimeout(timeout)
s = ssl_mod.wrap_socket(
s,
Expand Down

0 comments on commit 7e34618

Please sign in to comment.