_HTTPSConnection = httplib.HTTPSConnection
-# Try to save the original types for requests
-try:
- import requests.packages.urllib3.connectionpool as cpool
-except ImportError: # pragma: no cover
- pass
-else:
- _VerifiedHTTPSConnection = cpool.VerifiedHTTPSConnection
- _cpoolHTTPConnection = cpool.HTTPConnection
- _cpoolHTTPSConnection = cpool.HTTPSConnection
-
# Try to save the original types for boto3
try:
import botocore.vendored.requests.packages.urllib3.connectionpool as cpool
_cpoolBoto3HTTPConnection = cpool.HTTPConnection
_cpoolBoto3HTTPSConnection = cpool.HTTPSConnection
-
+cpool = None
# Try to save the original types for urllib3
try:
- import urllib3
+ import urllib3.connectionpool as cpool
except ImportError: # pragma: no cover
pass
else:
- _VerifiedHTTPSConnection = urllib3.connectionpool.VerifiedHTTPSConnection
+ _VerifiedHTTPSConnection = cpool.VerifiedHTTPSConnection
+ _cpoolHTTPConnection = cpool.HTTPConnection
+ _cpoolHTTPSConnection = cpool.HTTPSConnection
+
+# Try to save the original types for requests
+try:
+ if not cpool:
+ import requests.packages.urllib3.connectionpool as cpool
+except ImportError: # pragma: no cover
+ pass
+else:
+ _VerifiedHTTPSConnection = cpool.VerifiedHTTPSConnection
+ _cpoolHTTPConnection = cpool.HTTPConnection
+ _cpoolHTTPSConnection = cpool.HTTPSConnection
+
+
+
# Try to save the original types for httplib2
def _requests(self):
try:
- import requests.packages.urllib3.connectionpool as cpool
- except ImportError: # pragma: no cover
+ from .stubs import requests_stubs
+ except ImportError: # pragma: no cover
return ()
- from .stubs import requests_stubs
return self._urllib3_patchers(cpool, requests_stubs)
def _boto3(self):
'''Stubs for requests'''
try:
- from requests.packages.urllib3.connectionpool import HTTPConnection, VerifiedHTTPSConnection
-except ImportError:
from urllib3.connectionpool import HTTPConnection, VerifiedHTTPSConnection
+except ImportError:
+ from requests.packages.urllib3.connectionpool import HTTPConnection, VerifiedHTTPSConnection
from ..stubs import VCRHTTPConnection, VCRHTTPSConnection