summaryrefslogtreecommitdiff
path: root/tasks/vendoring/patches/requests.patch
blob: 75bf25ab28439cd830bcb20bc809c3d01985f28a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
diff --git a/src/pip/_vendor/requests/packages.py b/src/pip/_vendor/requests/packages.py
index 6336a07d..9582fa73 100644
--- a/src/pip/_vendor/requests/packages.py
+++ b/src/pip/_vendor/requests/packages.py
@@ -4,11 +4,13 @@ import sys
 # I don't like it either. Just look the other way. :)

 for package in ('urllib3', 'idna', 'chardet'):
-    locals()[package] = __import__(package)
+    vendored_package = "pip._vendor." + package
+    locals()[package] = __import__(vendored_package)
     # This traversal is apparently necessary such that the identities are
     # preserved (requests.packages.urllib3.* is urllib3.*)
     for mod in list(sys.modules):
-        if mod == package or mod.startswith(package + '.'):
-            sys.modules['requests.packages.' + mod] = sys.modules[mod]
+        if mod == vendored_package or mod.startswith(vendored_package + '.'):
+            unprefixed_mod = mod[len("pip._vendor."):]
+            sys.modules['pip._vendor.requests.packages.' + unprefixed_mod] = sys.modules[mod]

 # Kinda cool, though, right?

diff --git a/src/pip/_vendor/requests/__init__.py b/src/pip/_vendor/requests/__init__.py
index 9c3b769..36a4ef40 100644
--- a/src/pip/_vendor/requests/__init__.py
+++ b/src/pip/_vendor/requests/__init__.py
@@ -80,13 +80,15 @@ except (AssertionError, ValueError):
                   RequestsDependencyWarning)

 # Attempt to enable urllib3's SNI support, if possible
-try:
-    from pip._vendor.urllib3.contrib import pyopenssl
-    pyopenssl.inject_into_urllib3()
-
-    # Check cryptography version
-    from cryptography import __version__ as cryptography_version
-    _check_cryptography(cryptography_version)
-except ImportError:
-    pass
+from pip._internal.utils.compat import WINDOWS
+if not WINDOWS:
+    try:
+        from pip._vendor.urllib3.contrib import pyopenssl
+        pyopenssl.inject_into_urllib3()
+
+        # Check cryptography version
+        from cryptography import __version__ as cryptography_version
+        _check_cryptography(cryptography_version)
+    except ImportError:
+        pass

 # urllib3's DependencyWarnings should be silenced.
diff --git a/src/pip/_vendor/requests/compat.py b/src/pip/_vendor/requests/compat.py
index eb6530d..353ec29 100644
--- a/src/pip/_vendor/requests/compat.py
+++ b/src/pip/_vendor/requests/compat.py
@@ -25,10 +25,14 @@
 #: Python 3.x?
 is_py3 = (_ver[0] == 3)

-try:
-    import simplejson as json
-except ImportError:
-    import json
+# Note: We've patched out simplejson support in pip because it prevents
+#       upgrading simplejson on Windows.
+# try:
+#     import simplejson as json
+# except (ImportError, SyntaxError):
+#     # simplejson does not support Python 3.2, it throws a SyntaxError
+#     # because of u'...' Unicode literals.
+import json

 # ---------
 # Specifics