Skip to content

Commit d2de289

Browse files
author
Matt Long
committed
Update requests patch
1 parent d3ac4a4 commit d2de289

File tree

1 file changed

+111
-16
lines changed

1 file changed

+111
-16
lines changed
Lines changed: 111 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
diff --git a/pip/_vendor/requests/__init__.py b/pip/_vendor/requests/__init__.py
2-
index 9c3b769..44f6836 100644
2+
index 9c3b7695..a041ca73 100644
33
--- a/pip/_vendor/requests/__init__.py
44
+++ b/pip/_vendor/requests/__init__.py
5-
@@ -48,11 +48,13 @@ __license__ = 'Apache 2.0'
5+
@@ -48,11 +48,16 @@ __license__ = 'Apache 2.0'
66
__copyright__ = 'Copyright 2016 Kenneth Reitz'
77

88
# Attempt to enable urllib3's SNI support, if possible
@@ -13,19 +13,22 @@ index 9c3b769..44f6836 100644
1313
- pass
1414
+# Note: Patched by pip to prevent using the PyOpenSSL module. On Windows this
1515
+# prevents upgrading cryptography.
16-
+# try:
17-
+# from .packages.urllib3.contrib import pyopenssl
18-
+# pyopenssl.inject_into_urllib3()
19-
+# except ImportError:
20-
+# pass
16+
+from pip.compat import LOAD_C_DEPENDENCIES
17+
+if LOAD_C_DEPENDENCIES:
18+
+ try:
19+
+ from .packages.urllib3.contrib import pyopenssl
20+
+ pyopenssl.inject_into_urllib3()
21+
+ except ImportError:
22+
+ pass
23+
+del LOAD_C_DEPENDENCIES
2124

2225
import warnings
2326

2427
diff --git a/pip/_vendor/requests/compat.py b/pip/_vendor/requests/compat.py
25-
index eb6530d..353ec29 100644
28+
index eb6530d6..ea328f63 100644
2629
--- a/pip/_vendor/requests/compat.py
2730
+++ b/pip/_vendor/requests/compat.py
28-
@@ -25,12 +25,14 @@ is_py2 = (_ver[0] == 2)
31+
@@ -25,12 +25,19 @@ is_py2 = (_ver[0] == 2)
2932
#: Python 3.x?
3033
is_py3 = (_ver[0] == 3)
3134

@@ -34,15 +37,107 @@ index eb6530d..353ec29 100644
3437
-except (ImportError, SyntaxError):
3538
- # simplejson does not support Python 3.2, it throws a SyntaxError
3639
- # because of u'...' Unicode literals.
37-
- import json
3840
+# Note: We've patched out simplejson support in pip because it prevents
3941
+# upgrading simplejson on Windows.
40-
+# try:
41-
+# import simplejson as json
42-
+# except (ImportError, SyntaxError):
43-
+# # simplejson does not support Python 3.2, it throws a SyntaxError
44-
+# # because of u'...' Unicode literals.
45-
+import json
42+
+from pip.compat import LOAD_C_DEPENDENCIES
43+
+if LOAD_C_DEPENDENCIES:
44+
+ try:
45+
+ import simplejson as json
46+
+ except (ImportError, SyntaxError):
47+
+ # simplejson does not support Python 3.2, it throws a SyntaxError
48+
+ # because of u'...' Unicode literals.
49+
+ import json
50+
+else:
51+
import json
52+
+del LOAD_C_DEPENDENCIES
4653

4754
# ---------
4855
# Specifics
56+
diff --git a/pip/_vendor/requests/packages/urllib3/util/ssl_.py b/pip/_vendor/requests/packages/urllib3/util/ssl_.py
57+
index 4a64d7ef..4fb3047f 100644
58+
--- a/pip/_vendor/requests/packages/urllib3/util/ssl_.py
59+
+++ b/pip/_vendor/requests/packages/urllib3/util/ssl_.py
60+
@@ -112,15 +112,32 @@ except ImportError:
61+
self.ciphers = cipher_suite
62+
63+
def wrap_socket(self, socket, server_hostname=None, server_side=False):
64+
- warnings.warn(
65+
- 'A true SSLContext object is not available. This prevents '
66+
- 'urllib3 from configuring SSL appropriately and may cause '
67+
- 'certain SSL connections to fail. You can upgrade to a newer '
68+
- 'version of Python to solve this. For more information, see '
69+
- 'https://urllib3.readthedocs.io/en/latest/security.html'
70+
- '#insecureplatformwarning.',
71+
- InsecurePlatformWarning
72+
- )
73+
+ from pip.compat import LOAD_C_DEPENDENCIES
74+
+ if LOAD_C_DEPENDENCIES:
75+
+ warnings.warn(
76+
+ 'A true SSLContext object is not available. This prevents '
77+
+ 'urllib3 from configuring SSL appropriately and may cause '
78+
+ 'certain SSL connections to fail. You can upgrade to a newer '
79+
+ 'version of Python to solve this. For more information, see '
80+
+ 'https://urllib3.readthedocs.io/en/latest/security.html'
81+
+ '#insecureplatformwarning.',
82+
+ InsecurePlatformWarning
83+
+ )
84+
+ else:
85+
+ warnings.warn(
86+
+ 'A true SSLContext object is not available. This prevents '
87+
+ 'urllib3 from configuring SSL appropriately and may cause '
88+
+ 'certain SSL connections to fail. You can upgrade to a newer '
89+
+ 'version of Python to solve this. For more information, see '
90+
+ 'https://urllib3.readthedocs.io/en/latest/security.html'
91+
+ '#insecureplatformwarning. '
92+
+ 'NOTE: Since pip uses vendored versions of '
93+
+ 'requests and urllib3 and cannot load C dependencies based '
94+
+ 'on the current platform, installing additional security '
95+
+ 'packages will NOT resolve this warning.',
96+
+ InsecurePlatformWarning
97+
+ )
98+
+
99+
kwargs = {
100+
'keyfile': self.keyfile,
101+
'certfile': self.certfile,
102+
@@ -307,14 +324,31 @@ def ssl_wrap_socket(sock, keyfile=None, certfile=None, cert_reqs=None,
103+
if HAS_SNI: # Platform-specific: OpenSSL with enabled SNI
104+
return context.wrap_socket(sock, server_hostname=server_hostname)
105+
106+
- warnings.warn(
107+
- 'An HTTPS request has been made, but the SNI (Subject Name '
108+
- 'Indication) extension to TLS is not available on this platform. '
109+
- 'This may cause the server to present an incorrect TLS '
110+
- 'certificate, which can cause validation failures. You can upgrade to '
111+
- 'a newer version of Python to solve this. For more information, see '
112+
- 'https://urllib3.readthedocs.io/en/latest/security.html'
113+
- '#snimissingwarning.',
114+
- SNIMissingWarning
115+
- )
116+
+ from pip.compat import LOAD_C_DEPENDENCIES
117+
+ if LOAD_C_DEPENDENCIES:
118+
+ warnings.warn(
119+
+ 'An HTTPS request has been made, but the SNI (Subject Name '
120+
+ 'Indication) extension to TLS is not available on this platform. '
121+
+ 'This may cause the server to present an incorrect TLS '
122+
+ 'certificate, which can cause validation failures. You can upgrade to '
123+
+ 'a newer version of Python to solve this. For more information, see '
124+
+ 'https://urllib3.readthedocs.io/en/latest/security.html'
125+
+ '#snimissingwarning.',
126+
+ SNIMissingWarning
127+
+ )
128+
+ else:
129+
+ warnings.warn(
130+
+ 'An HTTPS request has been made, but the SNI (Subject Name '
131+
+ 'Indication) extension to TLS is not available on this platform. '
132+
+ 'This may cause the server to present an incorrect TLS '
133+
+ 'certificate, which can cause validation failures. You can upgrade to '
134+
+ 'a newer version of Python to solve this. For more information, see '
135+
+ 'https://urllib3.readthedocs.io/en/latest/security.html'
136+
+ '#snimissingwarning. '
137+
+ 'NOTE: Since pip uses vendored versions of '
138+
+ 'requests and urllib3 and cannot load C dependencies based '
139+
+ 'on the current platform, installing additional security '
140+
+ 'packages will NOT resolve this warning.',
141+
+ SNIMissingWarning
142+
+ )
143+
return context.wrap_socket(sock)

0 commit comments

Comments
 (0)