mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-22 09:26:37 +03:00
Fix import ssl may fail under some Python installs
It's only required for certain proxy configurations, so we don't want it to raise ImportError while the user imports our library.
This commit is contained in:
parent
6850903d17
commit
7e346180d7
|
@ -1,9 +1,13 @@
|
||||||
import abc
|
import abc
|
||||||
import asyncio
|
import asyncio
|
||||||
import socket
|
import socket
|
||||||
import ssl as ssl_mod
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
try:
|
||||||
|
import ssl as ssl_mod
|
||||||
|
except ImportError:
|
||||||
|
ssl_mod = None
|
||||||
|
|
||||||
from ...errors import InvalidChecksumError
|
from ...errors import InvalidChecksumError
|
||||||
from ... import helpers
|
from ... import helpers
|
||||||
|
|
||||||
|
@ -68,6 +72,12 @@ class Connection(abc.ABC):
|
||||||
loop=self._loop
|
loop=self._loop
|
||||||
)
|
)
|
||||||
if ssl:
|
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.settimeout(timeout)
|
||||||
s = ssl_mod.wrap_socket(
|
s = ssl_mod.wrap_socket(
|
||||||
s,
|
s,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user