File tree 3 files changed +33
-26
lines changed
3 files changed +33
-26
lines changed Original file line number Diff line number Diff line change 1
1
#!/usr/bin/env python
2
- from __future__ import absolute_import
3
-
4
- import warnings
5
-
6
- # We ignore certain warnings from urllib3, since they are not relevant to pip's
7
- # usecases.
8
- from pip ._vendor .urllib3 .exceptions import InsecureRequestWarning
9
-
10
2
import pip ._internal .utils .inject_securetransport # noqa
11
-
12
- # Raised when using --trusted-host.
13
- warnings .filterwarnings ("ignore" , category = InsecureRequestWarning )
Original file line number Diff line number Diff line change 12
12
import os
13
13
import platform
14
14
import sys
15
+ import warnings
15
16
16
17
from pip ._vendor import requests , six , urllib3
17
18
from pip ._vendor .cachecontrol import CacheControlAdapter
18
19
from pip ._vendor .requests .adapters import BaseAdapter , HTTPAdapter
19
20
from pip ._vendor .requests .models import Response
20
21
from pip ._vendor .requests .structures import CaseInsensitiveDict
21
22
from pip ._vendor .six .moves .urllib import parse as urllib_parse
23
+ from pip ._vendor .urllib3 .exceptions import InsecureRequestWarning
22
24
23
25
from pip import __version__
24
26
from pip ._internal .network .auth import MultiDomainBasicAuth
48
50
logger = logging .getLogger (__name__ )
49
51
50
52
53
+ # Ignore warning raised when using --trusted-host.
54
+ warnings .filterwarnings ("ignore" , category = InsecureRequestWarning )
55
+
56
+
51
57
SECURE_ORIGINS = [
52
58
# protocol, hostname, port
53
59
# Taken from Chrome's list of secure origins (See: http://bit.ly/1qrySKC)
Original file line number Diff line number Diff line change 7
7
old to handle TLSv1.2.
8
8
"""
9
9
10
- try :
11
- import ssl
12
- except ImportError :
13
- pass
14
- else :
15
- import sys
16
-
17
- # Checks for OpenSSL 1.0.1 on MacOS
18
- if sys .platform == "darwin" and ssl .OPENSSL_VERSION_NUMBER < 0x1000100f :
19
- try :
20
- from pip ._vendor .urllib3 .contrib import securetransport
21
- except (ImportError , OSError ):
22
- pass
23
- else :
24
- securetransport .inject_into_urllib3 ()
10
+ import sys
11
+
12
+
13
+ def inject_securetransport ():
14
+ # type: () -> None
15
+ # Only relevant on macOS
16
+ if sys .platform != "darwin" :
17
+ return
18
+
19
+ try :
20
+ import ssl
21
+ except ImportError :
22
+ return
23
+
24
+ # Checks for OpenSSL 1.0.1
25
+ if ssl .OPENSSL_VERSION_NUMBER >= 0x1000100f :
26
+ return
27
+
28
+ try :
29
+ from pip ._vendor .urllib3 .contrib import securetransport
30
+ except (ImportError , OSError ):
31
+ return
32
+
33
+ securetransport .inject_into_urllib3 ()
34
+
35
+
36
+ inject_securetransport ()
You can’t perform that action at this time.
0 commit comments