Skip to content

Commit 2f76fbe

Browse files
pipamp343
pip
authored andcommitted
Limit the disabling of requests' pyopenssl import to Windows
1 parent 26c5c4e commit 2f76fbe

File tree

4 files changed

+31
-19
lines changed

4 files changed

+31
-19
lines changed

news/4098.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Limit the disabling of requests' pyopenssl to Windows only. Fixes "SNIMissingWarning / InsecurePlatformWarning not fixable with pip 9.0 / 9.0.1" (for non-Windows)

pip/_vendor/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ Modifications
9797
* ``pkg_resources`` has been modified to import its dependencies from ``pip._vendor``
9898
* ``CacheControl`` has been modified to import its dependencies from ``pip._vendor``
9999
* ``packaging`` has been modified to import its dependencies from ``pip._vendor``
100-
* ``requests`` has been modified *not* to optionally load any C dependencies
100+
* ``requests`` has been modified to *not* load C dependencies: ``simplejson`` (all platforms) and ``pyopenssl`` (Windows)
101101
* Modified distro to delay importing ``argparse`` to avoid errors on 2.6
102102

103103

pip/_vendor/requests/__init__.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,19 @@
4747
__license__ = 'Apache 2.0'
4848
__copyright__ = 'Copyright 2016 Kenneth Reitz'
4949

50+
51+
from pip.compat import WINDOWS
52+
53+
5054
# Attempt to enable urllib3's SNI support, if possible
51-
# Note: Patched by pip to prevent using the PyOpenSSL module. On Windows this
52-
# prevents upgrading cryptography.
53-
# try:
54-
# from .packages.urllib3.contrib import pyopenssl
55-
# pyopenssl.inject_into_urllib3()
56-
# except ImportError:
57-
# pass
55+
# Note: Patched by pip to prevent using the PyOpenSSL module when OS is Windows.
56+
# Otherwise on Windows this would prevent upgrading cryptography.
57+
if not WINDOWS:
58+
try:
59+
from .packages.urllib3.contrib import pyopenssl
60+
pyopenssl.inject_into_urllib3()
61+
except ImportError:
62+
pass
5863

5964
import warnings
6065

tasks/vendoring/patches/requests.patch

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
11
diff --git a/pip/_vendor/requests/__init__.py b/pip/_vendor/requests/__init__.py
2-
index 9c3b769..44f6836 100644
2+
index 9c3b769..36a4ef40 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+
@@ -47,12 +47,19 @@ __author__ = 'Kenneth Reitz'
6+
__license__ = 'Apache 2.0'
67
__copyright__ = 'Copyright 2016 Kenneth Reitz'
7-
8+
9+
+
10+
+from pip.compat import WINDOWS
11+
+
12+
+
813
# Attempt to enable urllib3's SNI support, if possible
914
-try:
1015
- from .packages.urllib3.contrib import pyopenssl
1116
- pyopenssl.inject_into_urllib3()
1217
-except ImportError:
1318
- pass
14-
+# Note: Patched by pip to prevent using the PyOpenSSL module. On Windows this
15-
+# prevents upgrading cryptography.
16-
+# try:
17-
+# from .packages.urllib3.contrib import pyopenssl
18-
+# pyopenssl.inject_into_urllib3()
19-
+# except ImportError:
20-
+# pass
21-
19+
+# Note: Patched by pip to prevent using the PyOpenSSL module when OS is Windows.
20+
+# Otherwise on Windows this would prevent upgrading cryptography.
21+
+if not WINDOWS:
22+
+ try:
23+
+ from .packages.urllib3.contrib import pyopenssl
24+
+ pyopenssl.inject_into_urllib3()
25+
+ except ImportError:
26+
+ pass
27+
2228
import warnings
2329

2430
diff --git a/pip/_vendor/requests/compat.py b/pip/_vendor/requests/compat.py

0 commit comments

Comments
 (0)