mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2025-03-14 19:48:57 +01:00
request.py: Fix warning on stderr irrelevant for most users
Attempting to import urllib3.contrib.socks may fail if PySocks is not installed. Most users won't care for that. Only import that module if the user requested to use a socks proxy.
This commit is contained in:
parent
284f16b87b
commit
fe5ae8ed84
1 changed files with 3 additions and 5 deletions
|
@ -31,10 +31,6 @@ import urllib3
|
|||
import urllib3.contrib.appengine
|
||||
from urllib3.connection import HTTPConnection
|
||||
from urllib3.util.timeout import Timeout
|
||||
try:
|
||||
from urllib3.contrib.socks import SOCKSProxyManager
|
||||
except ImportError:
|
||||
SOCKSProxyManager = None
|
||||
|
||||
from telegram import (InputFile, TelegramError)
|
||||
from telegram.error import (Unauthorized, NetworkError, TimedOut, BadRequest, ChatMigrated,
|
||||
|
@ -102,7 +98,9 @@ class Request(object):
|
|||
else:
|
||||
kwargs.update(urllib3_proxy_kwargs)
|
||||
if proxy_url.startswith('socks'):
|
||||
if not SOCKSProxyManager:
|
||||
try:
|
||||
from urllib3.contrib.socks import SOCKSProxyManager
|
||||
except ImportError:
|
||||
raise RuntimeError('PySocks is missing')
|
||||
mgr = SOCKSProxyManager(proxy_url, **kwargs)
|
||||
else:
|
||||
|
|
Loading…
Add table
Reference in a new issue