Avoid confusion with user's urllib3 by renaming vendored urllib3

This commit is contained in:
Noam Meltzer 2017-05-23 00:21:51 +03:00
parent 23b37c9ea4
commit ff897ce9ef
6 changed files with 15 additions and 11 deletions

2
.gitmodules vendored
View file

@ -1,4 +1,4 @@
[submodule "telegram/vendor/urllib3"]
path = telegram/vendor/urllib3
path = telegram/vendor/ptb_urllib3
url = https://github.com/python-telegram-bot/urllib3.git
branch = ptb

View file

@ -22,8 +22,6 @@ from sys import version_info
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'vendor', 'urllib3'))
from .base import TelegramObject
from .user import User
from .chat import Chat

View file

@ -20,6 +20,7 @@
import os
import socket
import logging
import warnings
try:
import ujson as json
@ -27,10 +28,15 @@ except ImportError:
import json
import certifi
import urllib3
import urllib3.contrib.appengine
from urllib3.connection import HTTPConnection
from urllib3.util.timeout import Timeout
try:
import telegram.vendor.ptb_urllib3.urllib3 as urllib3
import telegram.vendor.ptb_urllib3.urllib3.contrib.appengine as appengine
from telegram.vendor.ptb_urllib3.urllib3.connection import HTTPConnection
from telegram.vendor.ptb_urllib3.urllib3.util.timeout import Timeout
except ImportError:
warnings.warn("python-telegram-bot wasn't properly installed. Please refer to README.rst on "
"how to properly install.")
raise
from telegram import (InputFile, TelegramError)
from telegram.error import (Unauthorized, NetworkError, TimedOut, BadRequest, ChatMigrated,
@ -90,16 +96,16 @@ class Request(object):
proxy_url = os.environ.get('HTTPS_PROXY') or os.environ.get('https_proxy')
if not proxy_url:
if urllib3.contrib.appengine.is_appengine_sandbox():
if appengine.is_appengine_sandbox():
# Use URLFetch service if running in App Engine
mgr = urllib3.contrib.appengine.AppEngineManager()
mgr = appengine.AppEngineManager()
else:
mgr = urllib3.PoolManager(**kwargs)
else:
kwargs.update(urllib3_proxy_kwargs)
if proxy_url.startswith('socks'):
try:
from urllib3.contrib.socks import SOCKSProxyManager
from telegram.vendor.ptb_urllib3.urllib3.contrib.socks import SOCKSProxyManager
except ImportError:
raise RuntimeError('PySocks is missing')
mgr = SOCKSProxyManager(proxy_url, **kwargs)

0
telegram/vendor/__init__.py vendored Normal file
View file

1
telegram/vendor/ptb_urllib3 vendored Submodule

@ -0,0 +1 @@
Subproject commit 60cec0d2dbd1016a889fa98e4dec6a3b1bd2e799

@ -1 +0,0 @@
Subproject commit 4b076eedffc1afabf0215ced3820603de73d1ce7